TypeProvider

TypeProvider

Stable Interface

What it does

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

How to use

@Injectable()
class MyService {}

const provider: TypeProvider = MyService;

Interface Overview

interface TypeProvider extends Type {
}

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

@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

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v2.angular.io/docs/ts/latest/api/core/index/TypeProvider-interface.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部