javascript - Difference in these two ways of declaring AngularJS controller? -


are these 2 equal?

is latter "shorthand way" write controller?

angular.module("root", []) .controller("index", ["$scope", function ($scope) {     // .. }]); 

vs

angular.module("root", []) .controller("index", function ($scope) {     // .. }); 

thanks!

the duplication of names strings (they call property annotation) protection against mangling. javascript minifiers mangle variable names, prevents angular being able dependencies name inject them. mangling has no effect on strings, if they're annotated, injector can still them up.

you can drop property annotation if you're absolutely, positively sure code won't mangled. if you're working in collaboration someone, or if you're writing library, use it.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -