Angularjs minify best practice
I'm reading
http://www.alexrothenberg.com/2013/02/11/the-magic-behind-angularjs-dependency-injection.html
and it turned out that angularjs dependency injection has problems if you
minify your javascript so I'm wondering if instead of
var MyController = function($scope, $http) {
$http.get('https://api.github.com/repos/angular/angular.js/commits')
.success(function(commits) {
$scope.commits = commits
})
}
you should use
var MyController = ['$scope', '$http', function($scope, $http) {
$http.get('https://api.github.com/repos/angular/angular.js/commits')
.success(function(commits) {
$scope.commits = commits
})
}]
all in all I thought the second snippet was for the old version of
angularjs but ....
Should I always use the inject way (the second one) ?
No comments:
Post a Comment