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

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -