Roh*_*t13 9 javascript angularjs angularjs-controller
我是AngularJS的新手.使用数组参数声明的控制器之间的区别是什么,将依赖关系列为字符串和JavaScript名称,
app.controller("firstController", ['$scope', '$modal', '$log', 'HttpService', 'FisrtSharedService', 'SecondSharedService', function($scope, $modal, $log, HttpService, FisrtSharedService, SecondSharedService) {
}]);
Run Code Online (Sandbox Code Playgroud)
...和这个表单,只列出JavaScript名称?
app.controller("firstController", function($scope, $modal, $log, HttpService, FisrtSharedService, SecondSharedService){
});
Run Code Online (Sandbox Code Playgroud)
为什么第一个版本中的奇怪语法?
duc*_*dhm 12
当你缩小JS文件时使用它.'$scope', '$modal', '$log', 'HttpService', 'FisrtSharedService', 'SecondSharedService'只是声明注射器.
app.controller("firstController", ['$scope', '$modal', '$log', 'HttpService', 'FisrtSharedService', 'SecondSharedService', function($scope, $modal, $log, HttpService, FisrtSharedService, SecondSharedService) {
}]);
Run Code Online (Sandbox Code Playgroud)
您还要声明这样的注射器:
firstController.$inject = ['$scope', '$modal', '$log', 'HttpService', 'FisrtSharedService', 'SecondSharedService'];
app.controller("firstController", function($scope, $modal, $log, HttpService, FisrtSharedService, SecondSharedService){
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3946 次 |
| 最近记录: |