Answer the question
In order to leave comments, you need to log in
How to inherit a class with injections?
There is a base class into which the service is injected. When inheriting this class and calling the super method in the child, it swears that the base class constructor takes one argument, that is, a service injection. At the moment I did this:
constructor(
protected service: MyService
) {
super(service);
}
const injector = ReflectiveInjector.resolveAndCreate([MyService]);
this.service= injector.get(MyService);
Answer the question
In order to leave comments, you need to log in
Don't inherit a service, @injectable class, pass it as a dependency.
Google creating services through factories.
In providers, instead of a service class, pass an object with properties useFactory, provide and deps, to deps injectable classes, they are the same services that the service specified in provide
uses. Not at home right now, if it doesn’t work out, write, I’ll be at the computer in the evening, I’ll throw some code)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question