What does the trackBy function on ngFor do?
- A Tracks user analytics
- B Tells Angular how to identify items so it can reuse DOM nodes instead of recreating them
- C Sorts the list
- D Filters the list
Answer
Tells Angular how to identify items so it can reuse DOM nodes instead of recreating them
Without trackBy, changing the array causes Angular to destroy and rebuild every element, which is costly and loses component state.





