Get Angular 2 Service Inside A Custom Class Instantiated By Me
Im building an angular 2 app, and i need a way to get a reference to a service/class that is injected/instantiated by angular framework. I have a generic class...lets call it Custo
Solution 1:
As far as I know you have two choices:
1) Manually pass the service into the Custom class constructor.
let x = new Custom(this.userService);
2) Make the Custom class a service as well. Then it will participate in Angular's DI.
See this article for more information: https://blog.thoughtram.io/angular/2015/05/18/dependency-injection-in-angular-2.html
Post a Comment for "Get Angular 2 Service Inside A Custom Class Instantiated By Me"