Angularjs缩小最佳实践我在读http:/www.alexrotenberg.com/2013/02/11/the-魔术-后台-angularjs-依赖-injection.html结果发现,如果缩小javascript的话,angularjs依赖注入就会有问题,所以我想知道是不是var MyController = function($scope, $http) {
$http.get('https://api.github.com/repos/angular/angular.js/commits')
.success(function(commits) {
$scope.commits = commits })
}你应该用var MyController = ['$scope', '$http', function($scope, $http) {
$http.get('https://api.github.com/repos/angular/angular.js/commits')
.success(function(commits) {
$scope.commits = commits })}]总之,我以为第二个片段是给老版本的安古拉杰的,但是.我应该总是使用注射方式(第二种方式)吗?
添加回答
举报
0/150
提交
取消