InjectMetadata

export class InjectMetadata

exported from angular2/core defined in angular2/src/core/di/metadata.ts (line 1)

A parameter metadata that specifies a dependency.

Example (live demo)

class Engine {} @Injectable() class Car { engine; constructor(@Inject("MyEngine") engine:Engine) { this.engine = engine; } } var injector = Injector.resolveAndCreate([ provide("MyEngine", {useClass: Engine}), Car ]); expect(injector.get(Car).engine instanceof Engine).toBe(true);

When @Inject() is not present, Injector will use the type annotation of the parameter.

Example

class Engine {} @Injectable() class Car { constructor(public engine: Engine) {} //same as constructor(@Inject(Engine) engine:Engine) } var injector = Injector.resolveAndCreate([Engine, Car]); expect(injector.get(Car).engine instanceof Engine).toBe(true);

Constructor

constructor(token: any)

Not Yet Documented

Members

token

Not Yet Documented

toString() : string

Not Yet Documented