Skip to content

Commit 520736b

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Fixing error: "Cannot insert a destroyed View in a ViewContainer" when container size is changed.
1 parent 6002ee0 commit 520736b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,8 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
12301230
protected removeLastElem() {
12311231
const oldElem = this._embeddedViews.pop();
12321232
this.onBeforeViewDestroyed.emit(oldElem);
1233+
// also detach from ViewContainerRef to make absolutely sure this is removed from the view container.
1234+
this.dc.instance._vcr.detach(this.dc.instance._vcr.length - 1);
12331235
oldElem.destroy();
12341236

12351237
this.state.chunkSize--;

0 commit comments

Comments
 (0)