填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

TypeProvider

配置此 Injector,以将“类型”用作令牌时返回 Type 的实例。

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

查看"说明"...

      
      interface TypeProvider extends Type {

  // 继承自 core/Type
  constructor(...args: any[]): T
}
    

说明

通过调用 new 运算符并提供其他参数来创建实例。这种形式是 TypeProvider 的缩写形式;

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

使用说明

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

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

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