Why use `deps` property in DI Why use `deps` property in DI angular angular

Why use `deps` property in DI


This is a way to tell Angular dependency injections what dependencies it needs to inject to the factory function returned by runnersUpFactory.

For services there is the @Injectable() class to tell DI that it needs to analyze the constructor parameter of this class (same for @Component(), @Directive(), and @Pipe()), but this seems not to work for functions. Therefore they introduced the deps parameter.

DI will look up a provider using the key Hero and another one using HeroService and then will pass them as parameters to the factory function in the same order.

https://angular.io/docs/ts/latest/api/core/index/FactoryProvider-interface.html

deps : any[] A list of tokens which need to be resolved by the injector. The list of values is than used as arguments to the useFactory function.