Angular.js依赖项为第三方库排序

时间:2016-10-07 08:52:49

标签: angularjs dependency-injection angular-controller

首先,所有第三方库都应该包含在角度模块中,这样它就可以作为依赖项添加到其他角度模块中。

例如

angular.module('lodash', [])
      .factory('_', function($window) { return $window._;});

并将其注入其他模块,如:

angular.module('myApp', ['lodash']);

问题是,第三方库在开始或结束时应该在依赖列表中的哪个位置?

angular.module('myApp').controller(function($scope, _){});

VS

angular.module('myApp').controller(function(_, $scope){});

这两种情况都有效,但您对此有何看法?

提前谢谢

1 个答案:

答案 0 :(得分:0)

在这种情况下,订单并不重要。 Angularjs将自动处理依赖项之间的依赖关系。

相关问题