How to use `trackBy` with `ngFor`

On each ngDoCheck triggered for the ngForOf directive, Angular checks what objects have changed. It uses differs for this process and each differ uses the trackBy function to compare the current object with the new one. The default trackBy function tracks items by identity: const trackByIdentity = (index: number, item: any) => item; It receives … Read more