fix(ivy): optional dependencies should not throw with module injector (#26763)

PR Close #26763
This commit is contained in:
Kara Erickson
2018-10-25 11:35:51 -07:00
committed by Matias Niemelä
parent 1130e48541
commit 96770e5c6b
4 changed files with 94 additions and 44 deletions

View File

@ -368,6 +368,11 @@ export function getOrCreateInjectable<T>(
}
}
if (flags & InjectFlags.Optional && notFoundValue === undefined) {
// This must be set or the NullInjector will throw for optional deps
notFoundValue = null;
}
if ((flags & (InjectFlags.Self | InjectFlags.Host)) === 0) {
const moduleInjector = lViewData[INJECTOR];
if (moduleInjector) {