From fd3c6baec795c7b93aa22bf9a44eb95aaadb3b39 Mon Sep 17 00:00:00 2001 From: Manuel Mtz-Almeida Date: Wed, 19 Apr 2017 15:55:12 +0200 Subject: [PATCH] fix(virtual-scroll): create views inside zone fixes #10451 --- .../virtual-scroll/virtual-scroll.ts | 20 ++++++++++--------- src/components/virtual-scroll/virtual-util.ts | 7 ++++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/components/virtual-scroll/virtual-scroll.ts b/src/components/virtual-scroll/virtual-scroll.ts index 136b7d13eb..d64e1365bb 100644 --- a/src/components/virtual-scroll/virtual-scroll.ts +++ b/src/components/virtual-scroll/virtual-scroll.ts @@ -501,15 +501,17 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy { adjustRendered(cells, data); - populateNodeData( - data.topCell, data.bottomCell, - data.viewWidth, true, - cells, records, nodes, - this._itmTmp.viewContainer, - this._itmTmp.templateRef, - this._hdrTmp && this._hdrTmp.templateRef, - this._ftrTmp && this._ftrTmp.templateRef, needClean - ); + this._zone.run(() => { + populateNodeData( + data.topCell, data.bottomCell, + data.viewWidth, true, + cells, records, nodes, + this._itmTmp.viewContainer, + this._itmTmp.templateRef, + this._hdrTmp && this._hdrTmp.templateRef, + this._ftrTmp && this._ftrTmp.templateRef, needClean, + ); + }); if (needClean) { this._cd.detectChanges(); diff --git a/src/components/virtual-scroll/virtual-util.ts b/src/components/virtual-scroll/virtual-util.ts index 246b0bcd4e..cb9bad9fff 100644 --- a/src/components/virtual-scroll/virtual-util.ts +++ b/src/components/virtual-scroll/virtual-util.ts @@ -233,9 +233,10 @@ export function populateNodeData(startCellIndex: number, endCellIndex: number, v availableNode.cell = cellIndex; // apply the cell's data to this node - availableNode.view.context.$implicit = cell.data || records[cell.record]; - availableNode.view.context.index = cellIndex; - availableNode.view.context.count = recordsLength; + var context = availableNode.view.context; + context.$implicit = cell.data || records[cell.record]; + context.index = cellIndex; + context.count = recordsLength; availableNode.hasChanges = true; availableNode.lastTransform = null; hasChanges = true;