AngularJS依赖需求的差异

AngularJS difference in dependency requirement

本文关键字:需求 依赖 AngularJS      更新时间:2023-09-26

嗨,我正在学习AngularJS,我想知道定义你的依赖关系有什么不同:

angular.module('app.controllers')
.controller('myController', ['$scope', function ($scope) {
    // stuff
}]);
vs:

angular.module('app.controllers')
.controller('myController', function ($scope) {
    // stuff
});

只是想知道有什么不同:)

唯一的区别是,如果你缩小你的JavaScript,第二个选项将中断。

根据Maxim Shoustin和Chandermani的建议,这里有一些更详细的信息:

http://thegreenpizza.github.io/2013/05/25/building-minification-safe-angular.js-applications/https://docs.angularjs.org/guide/di