7
Angularjsはベストプラクティスを縮小します
私はhttp://www.alexrothenberg.com/2013/02/11/the-magic-behind-angularjs-dependency-injection.htmlを読んでい ますが、javascriptを縮小すると、angularjs依存性注入に問題があることがわかりました。の代わりに var MyController = function($scope, $http) { $http.get('https://api.github.com/repos/angular/angular.js/commits') .then(function(response) { $scope.commits = response.data }) } あなたは使うべきです var MyController = ['$scope', '$http', function($scope, $http) { $http.get('https://api.github.com/repos/angular/angular.js/commits') .then(function(response) { $scope.commits = response.data }) }] 全体的に見て、2番目のスニペットは古いバージョンのangularjs用のものだと思いましたが.... 常に注入方法(2番目)を使用する必要がありますか?