Use trackBy in Angular ngFor Loops and MatTables
Angular Logo (CC-BY 4.0 by Angular Team press Kit: https://angular.io/presskit).Read more →Note: This article was written for the old
*ngFor
syntax, whentrackBy
(calledtrack
in the new@for
syntax) was optional. For much of the same reasons outlined in this post,track
in the a@for
template is required.In most cases,
TrackByFunction
is no longer needed with the new syntax, since the example mentioned in this article could simply be written in the template as: