I already read the AngularJS documentation but still don\'t have an answer which I understand.
Why is this used twice? One time as array elements, the second as func
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.