Options
All
  • Public
  • Public/Protected
  • All
Menu

Class InjectionToken<T>

Creates a token that can be used in a DI Provider.

Use an InjectionToken whenever the type you are injecting is not reified (does not have a runtime representation) such as when injecting an interface, callable type, array or parametrized type.

InjectionToken is parameterized on T which is the type of object which will be returned by the Injector. This provides additional level of type safety.

interface MyInterface {...}
var myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken'));
// myInterface is inferred to be MyInterface.

Example

{@example core/di/ts/injector_spec.ts region='InjectionToken'}

stable

Type parameters

  • T

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

Protected _desc

_desc: string

Methods

toString

  • toString(): string

Generated using TypeDoc