Stable Interface
What it does
Configures the Injector
to return an instance of Type
when `Type' is used as token.
How to use
1 2 3 4 | @Injectable() class MyService {} const provider: TypeProvider = MyService; |
Interface Overview
1 2 | interface TypeProvider { } |
Interface Description
Create an instance by invoking the new
operator and supplying additional arguments. This form is a short form of TypeProvider
;
For more details, see the Dependency Injection Guide.
Example
1 2 3 4 5 6 7 8 9 10 | @Injectable() class Greeting { salutation = 'Hello' ; } const injector = ReflectiveInjector.resolveAndCreate([ Greeting, // Shorthand for { provide: Greeting, useClass: Greeting } ]); expect(injector.get(Greeting).salutation).toBe( 'Hello' ); |
exported from @angular/core/index, defined in @angular/core/src/di/provider.ts
Please login to continue.