Skip to content

Commit 635b19f

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Add check in case viewref is already empty.
1 parent b695601 commit 635b19f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

projects/igniteui-angular/src/lib/directives/template-outlet/template_outlet.directive.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ export class IgxTemplateOutletDirective implements OnChanges {
111111
// if view exists, but template has been changed and there is a view in the cache with the related template
112112
// then detach old view and insert the stored one with the matching template
113113
// after that update its context.
114-
this._viewContainerRef.detach(this._viewContainerRef.indexOf(this._viewRef));
114+
if (this._viewContainerRef.length > 0) {
115+
this._viewContainerRef.detach(this._viewContainerRef.indexOf(this._viewRef));
116+
}
117+
115118
this._viewRef = cachedView;
116119
const oldContext = this._cloneContext(cachedView.context);
117120
this._viewContainerRef.insert(this._viewRef, 0);

0 commit comments

Comments
 (0)