fix(ivy): DI should work when no element injector on starting node (#27133)

PR Close #27133
This commit is contained in:
Marc Laval
2018-11-16 15:25:38 +01:00
committed by Miško Hevery
parent 65943b458f
commit 848f4148c0
2 changed files with 72 additions and 2 deletions

View File

@ -321,8 +321,9 @@ export function getOrCreateInjectable<T>(
let injectorIndex = getInjectorIndex(tNode, lViewData);
let parentLocation: RelativeInjectorLocation = NO_PARENT_INJECTOR;
// If we should skip this injector, start by searching the parent injector.
if (flags & InjectFlags.SkipSelf) {
// If we should skip this injector, or if there is no injector on this node, start by searching
// the parent injector.
if (injectorIndex === -1 || flags & InjectFlags.SkipSelf) {
parentLocation = injectorIndex === -1 ? getParentInjectorLocation(tNode, lViewData) :
lViewData[injectorIndex + PARENT_INJECTOR];