OptionalMetadata

export class OptionalMetadata

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

A parameter metadata that marks a dependency as optional. Injector provides null if the dependency is not found.

Example (live demo)

class Engine {} @Injectable() class Car { engine; constructor(@Optional() engine:Engine) { this.engine = engine; } } var injector = Injector.resolveAndCreate([Car]); expect(injector.get(Car).engine).toBeNull();

Members

toString() : string

Not Yet Documented