diff --git a/modules/angular2/src/di/injector.ts b/modules/angular2/src/di/injector.ts index a26022544a..652c01eed9 100644 --- a/modules/angular2/src/di/injector.ts +++ b/modules/angular2/src/di/injector.ts @@ -141,6 +141,11 @@ export class Injector { this._syncStrategy = new _SyncInjectorStrategy(this); } + /** + * Direct parent of this injector. + */ + get parent(): Injector { return this._parent; } + /** * Retrieves an instance from the injector. * diff --git a/modules/angular2/test/di/injector_spec.js b/modules/angular2/test/di/injector_spec.js index 1d02e6644d..039c9344b0 100644 --- a/modules/angular2/test/di/injector_spec.js +++ b/modules/angular2/test/di/injector_spec.js @@ -348,6 +348,12 @@ export function main() { expect(childCar).toBe(parentCar); }); + + it("should give access to direct parent", () => { + var parent = Injector.resolveAndCreate([]); + var child = parent.resolveAndCreateChild([]); + expect(child.parent).toBe(parent); + }); }); describe("lazy", function () {