为什么 Angular 注入(inject)语法是这样的:
angular.module('myApp.services', [])
.factory('someService', ['$http', function($http) {
...
}]);
并且不是这样的,例如:
angular.module('myApp.services', [])
.factory('someService', function($http) {
...
});
看起来解释器在这两种情况下都会有相同的信息。但第二个的复杂性较低。
最佳答案
当您最小化当前文件时,第一种方法很有用。因为注入(inject)器按名称查找模块,所以您需要保持模块名称不最小化。因此,当您不最小化文件时可以使用第二种方法。
关于angularjs - Angular 注入(inject)语法背后的想法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33513785/