This question already has an answer here:
When I run the code, Option A
is failed but not sure what the reason is.
angular.module('app').controller('controllerA', function($scope, $http) {
// code
}
angular.module('app').controller('controllerB', ['$scope', '$http', function($scope, $http) {
// code
}]);
I tried to test it on Angular 1.x JSFiddle, but both of them work well. Help me!
This makes much difference in the minification process. if you are using
angular.min.js
library then in the production, optionA
fails. in JSFiddle u might useangular.js
lib. That's why both scenarios work.Check this for more information about minification
try below example
Both will work, but you should follow the second example, which uses the Array syntax so you can minify your code without worrying about the minifier renaming function parameters