TypeProvider
interface
npm Package | @angular/core |
---|---|
Module | import { TypeProvider } from '@angular/core'; |
Source | core/src/di/provider.ts |
Interface Overview
interface TypeProvider extends Type {
}
How To Use
@Injectable()
class MyService {}
const provider: TypeProvider = MyService;
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
@Injectable()
class Greeting {
salutation = 'Hello';
}
const injector = ReflectiveInjector.resolveAndCreate([
Greeting, // Shorthand for { provide: Greeting, useClass: Greeting }
]);
expect(injector.get(Greeting).salutation).toBe('Hello');
© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v4.angular.io/api/core/TypeProvider