If you minify this code:
someModule.controller('MyController', function($scope, greeter) {
// ...
});
You'll end with (something like):
someModule.controller('MyController', function(a, b) {
// ...
});
Angular won't be able to inject the dependencies since the parameters names are lost.
On the other hand, if you minify this code:
someModule.controller('MyController', ['$scope', 'greeter', function($scope, greeter) {
// ...
}]);
You'll end with:
someModule.controller('MyController', ['$scope', 'greeter', function(a, b) {
// ...
}]);
The parameters names are available: Angular's DI is operational.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…