TypeProvider

From Get docs
< @angular/coreAngular/docs/11/api/core/typeprovider


TypeProvider

interface

Configures the Injector to return an instance of Type when `Type' is used as the token.

See more...

interface TypeProvider extends Type {

  // inherited from core/Type
  constructor(...args: any[]): T
}

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".

Further information available in the Usage Notes...

Usage notes

@Injectable()
class Greeting {
  salutation = 'Hello';
}

const injector = ReflectiveInjector.resolveAndCreate([
  Greeting,  // Shorthand for { provide: Greeting, useClass: Greeting }
]);

expect(injector.get(Greeting).salutation).toBe('Hello');

© 2010–2021 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v11.angular.io/api/core/TypeProvider