SkipSelf
decorator
stable
npm Package | @angular/core |
---|---|
Module | import { SkipSelf } from '@angular/core'; |
Source | core/src/di/metadata.ts |
How To Use
@Injectable() class Car { constructor(@SkipSelf() public engine:Engine) {} }
Description
For more details, see the "Dependency Injection Guide".
Example
class Dependency {} @Injectable() class NeedsDependency { constructor(@SkipSelf() public dependency: Dependency) { this.dependency = dependency; } } const parent = ReflectiveInjector.resolveAndCreate([Dependency]); const child = parent.resolveAndCreateChild([NeedsDependency]); expect(child.get(NeedsDependency).dependency instanceof Dependency).toBe(true); const inj = ReflectiveInjector.resolveAndCreate([Dependency, NeedsDependency]); expect(() => inj.get(NeedsDependency)).toThrowError();
© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v4.angular.io/api/core/SkipSelf