Skip to content

Commit 2185e7c

Browse files
committed
feat(di): expose parent injector
1 parent c82cc47 commit 2185e7c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

modules/angular2/src/di/injector.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ export class Injector {
141141
this._syncStrategy = new _SyncInjectorStrategy(this);
142142
}
143143

144+
/**
145+
* Direct parent of this injector.
146+
*/
147+
get parent(): Injector { return this._parent; }
148+
144149
/**
145150
* Retrieves an instance from the injector.
146151
*

modules/angular2/test/di/injector_spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,12 @@ export function main() {
348348

349349
expect(childCar).toBe(parentCar);
350350
});
351+
352+
it("should give access to direct parent", () => {
353+
var parent = Injector.resolveAndCreate([]);
354+
var child = parent.resolveAndCreateChild([]);
355+
expect(child.parent).toBe(parent);
356+
});
351357
});
352358

353359
describe("lazy", function () {

0 commit comments

Comments
 (0)