feat(di): expose parent injector
This commit is contained in:
parent
c82cc47767
commit
2185e7cee9
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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 () {
|
||||
|
|
Loading…
Reference in New Issue