I
I
Isaac Clark2018-04-18 02:14:00
Angular
Isaac Clark, 2018-04-18 02:14:00

How to replace Injector.create?

Hello.
I came across the fact that in the last angular Injector.create - depricatet Tell me
how to use this method now and how to replace it?
Here is what he writes: @deprecated from v5 use the new signature Injector.create(options)
What then should I use in my case if I have the following code:

const injector = Injector.create(inputProviders, this.container.parentInjector);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Mazhekin, 2018-04-18
@Dark_Knight

use

static create(options: {
        providers: StaticProvider[];
        parent?: Injector;
        name?: string;
    }): Injector;

in your case
const options = {
  providers: inputProviders,
  parent: this.container.parentInjector
};
const injector = Injector.create(options);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question