您好,我正在学习 AngularJS,我想知道定义依赖项有什么区别:
angular.module('app.controllers')
.controller('myController', ['$scope', function ($scope) {
// stuff
}]);
对比:
angular.module('app.controllers')
.controller('myController', function ($scope) {
// stuff
});
只是想知道有什么区别:)
最佳答案
唯一的区别是,如果您缩小 JavaScript,第二个选项将会中断。
根据 Maxim Shustin 和 Chandermani 的建议,这里有一些更详细的信息:
http://thegreenpizza.github.io/2013/05/25/building-minification-safe-angular.js-applications/ https://docs.angularjs.org/guide/di
关于javascript - AngularJS 在依赖要求上的差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24527117/