3 ms·
Hrm.... I don't think the angular documentation agrees with what you are saying: In the documentation on the $inject annotation: > Care must be taken that the
by altcognito 13y ago
Hrm.... I don't think the angular documentation agrees with what you are saying: In the documentation on the $inject annotation:
> Care must be taken that the $inject annotation is kept in sync with the actual arguments in the function declaration.
> This method of annotation is useful for controller declarations since it assigns the annotation information with the function.
- mbell 13y agoYou don't need to use angular's inline injection annotations if you don't want to. Angular can figure out the needed injection by the parameter name. This causes an issue when you minimize your code but ngmin solves that problem: https://github.com/btford/ngmin https://github.com/btford/ngmin For example: angular.module('app').controller('someController', function ($scope, ModelService, AuthService) { $scope.something = 'Blah'; }); Works just fine as long as it isn't minimized, and ngmin would turn it into something like: angular.module('app').controller('someController', ['$scope', 'ModelService', 'AuthService', function ($scope, ModelService, AuthService) { $scope.something = 'Blah'; }]); Which is then safe to run through a minimizer.
- CoffeeDregs 13y agoAgreed, there are corner cases in which Angular has the same issue (hence my note that Angular does better). This is really only an issue when seriously minifying (e.g. closure compiler) your application code and I tend to stay away from that.