This question already has an answer here:
Is there any difference between the following two code snippet? Both work.
1.
myApp.controller("myAppController", ["$scope", function($scope) {
// function body
}]);
2.
myApp.controller("myAppController", function($scope) {
// function body
});
Well, difference will create during minfication. If you don't follow the step1 , minification will break your code.
Uglify Version of your 1st code
Uglify Version of your 2nd code
If you follow step 1 , Angular will find definition of
o
from injection.But if you follow step 2 , Angular won't find definition of
o
from any source.