diff --git a/packages/core/src/render3/di.ts b/packages/core/src/render3/di.ts index 074ea3200e..d1852f59ac 100644 --- a/packages/core/src/render3/di.ts +++ b/packages/core/src/render3/di.ts @@ -572,9 +572,6 @@ class ViewContainerRef implements viewEngine_ViewContainerRef { createEmbeddedView( templateRef: viewEngine_TemplateRef, context?: C|undefined, index?: number|undefined): viewEngine_EmbeddedViewRef { - // set current view to container node's view - enterView(this._node.view, null); - const viewRef = templateRef.createEmbeddedView(context !); this.insert(viewRef, index); return viewRef; diff --git a/packages/core/src/render3/instructions.ts b/packages/core/src/render3/instructions.ts index 90635cfbe1..220717ac6a 100644 --- a/packages/core/src/render3/instructions.ts +++ b/packages/core/src/render3/instructions.ts @@ -431,9 +431,10 @@ export function renderEmbeddedTemplate( previousOrParentNode = null !; let cm: boolean = false; if (viewNode == null) { + // TODO: revisit setting currentView when re-writing view containers const view = createLView( - -1, renderer, createTView(currentView.tView.directiveRegistry), template, context, - LViewFlags.CheckAlways); + -1, renderer, createTView(currentView && currentView.tView.directiveRegistry), template, + context, LViewFlags.CheckAlways); viewNode = createLNode(null, LNodeType.View, null, view); cm = true; } @@ -443,7 +444,7 @@ export function renderEmbeddedTemplate( refreshDynamicChildren(); refreshDirectives(); } finally { - leaveView(currentView !.parent !); + leaveView(currentView && currentView !.parent !); isParent = _isParent; previousOrParentNode = _previousOrParentNode; }