TrackByFunction
传给 NgForOf
指令的可选函数,该函数定义如何跟踪可迭代对象中条目的更改。该函数接受迭代索引和条目 ID 作为参数。提供后,Angular 将根据函数的返回值的变化进行跟踪。
An optional function passed into the NgForOf
directive that defines how to track changes for items in an iterable. The function takes the iteration index and item ID. When supplied, Angular tracks changes by the return value of the function.
interface TrackByFunction<T> {
(index: number, item: T): any
}