diff --git a/packages/core/src/render3/instructions/shared.ts b/packages/core/src/render3/instructions/shared.ts index b9fec7ed51..a59b643d7b 100644 --- a/packages/core/src/render3/instructions/shared.ts +++ b/packages/core/src/render3/instructions/shared.ts @@ -63,7 +63,11 @@ export function refreshDescendantViews(lView: LView) { const tView = lView[TVIEW]; const creationMode = isCreationMode(lView); - // This needs to be set before children are processed to support recursive components + // This needs to be set before children are processed to support recursive components. + // This must be set to false immediately after the first creation run because in an + // ngFor loop, all the views will be created together before update mode runs and turns + // off firstTemplatePass. If we don't set it here, instances will perform directive + // matching, etc again and again. tView.firstTemplatePass = false; // Resetting the bindingIndex of the current LView as the next steps may trigger change detection. @@ -413,13 +417,6 @@ export function renderEmbeddedTemplate(viewToRender: LView, tView: TView, con oldView = enterView(viewToRender, viewToRender[T_HOST]); resetPreOrderHookFlags(viewToRender); executeTemplate(viewToRender, tView.template !, getRenderFlags(viewToRender), context); - - // This must be set to false immediately after the first creation run because in an - // ngFor loop, all the views will be created together before update mode runs and turns - // off firstTemplatePass. If we don't set it here, instances will perform directive - // matching, etc again and again. - tView.firstTemplatePass = false; - refreshDescendantViews(viewToRender); safeToRunHooks = true; } finally {