Difference between dependency injection between array and without array angular
Computer Science
sunov765
Question
Difference between dependency injection between array and without array angular
1 Answer
-
1. User Answers rslekshmi08
Reading angular docs on dependency injection, there are two minification-friendly methods to do this:
Inline Array Annotation:
module.factory("MyStuff",['dependency',function(dep){...}])
The $inject property:
function MyStuff(dep) {...}
MyStuff.$inject = ['dependency'];
module.factory("MyStuff",MyStuff);
The inline one (first) is recommended. In one of my projects the style guide insists on the use of $inject property. I also see $inject property form quite often in open source code.