feat(di): expose parent injector

This commit is contained in:
yjbanov 2015-05-08 16:24:17 -07:00
parent c82cc47767
commit 2185e7cee9
2 changed files with 11 additions and 0 deletions

View File

@ -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.
*

View File

@ -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 () {