An IterableChangeRecord describes an item reported by Angular’s iterable differ. Callbacks on IterableChanges receive a record for each relevant item, such as one that was added, moved, or removed. section 15.3.4
Table 15.5. The IterableChangeRecord properties
|
Name
|
Description
|
|
item
|
This property returns the data item.
|
|
trackById
|
This property returns the identity value if a
trackBy function is used.
|
|
currentIndex
|
This property returns the current index of the item in the collection.
|
|
previousIndex
|
This property returns the previous index of the item in the collection.
|
The record exposes item, currentIndex, and previousIndex; trackById supplies an identity value when a trackBy function is used. section 15.3.4
Create views for added items
In ngDoCheck, diff the collection and proceed only when changes is non-null. Pass a callback to forEachAddedItem; use each record’s item and currentIndex to create its embedded view. This avoids clearing and rebuilding every view on each check. Deletions and modifications require the directive to track which view belongs to each data object. section 15.3.4
