dependency injection - Is it necessary to inject $scope to a controller in angularjs? -
this question has answer here:
is there difference between following 2 code snippet? both work.
1.
myapp.controller("myappcontroller", ["$scope", function($scope) { // function body }]);
2.
myapp.controller("myappcontroller", function($scope) { // function body });
well, difference create during minfication. if don't follow step1 , minification break code.
uglify version of 1st code
myapp.controller("myappcontroller",["$scope",function(o){}])
uglify version of 2nd code
myapp.controller("myappcontroller",function(o){})
if follow step 1 , angular find definition of o
injection.
but if follow step 2 , angular won't find definition of o
source.
Comments
Post a Comment