fix(core): avoid eager providers re-initialization (#23559)

Fix a corner case where eager providers were getting constructed twice if the provider was requested before the initialization of the NgModule is complete.

PR Close #23559
This commit is contained in:
Vikram Subramanian
2018-04-26 06:25:30 -07:00
committed by Igor Minar
parent 5b96078624
commit 0c6dc45c85
2 changed files with 33 additions and 1 deletions

View File

@ -68,7 +68,10 @@ export function initNgModule(data: NgModuleData) {
for (let i = 0; i < def.providers.length; i++) {
const provDef = def.providers[i];
if (!(provDef.flags & NodeFlags.LazyProvider)) {
providers[i] = _createProviderInstance(data, provDef);
// Make sure the provider has not been already initialized outside this loop.
if (providers[i] === undefined) {
providers[i] = _createProviderInstance(data, provDef);
}
}
}
}