我正在为trackby:
自定义组件循环提供*ngFor
。 This is the example provided by angular:
<li *ngFor="let item of items; index as i; trackBy: trackByFn">...</li>
但是我从一个可观察的对象中遍历了一系列自定义组件:
<custom-component *ngFor="let item of (observable$ | async); trackBy: trackByFn"></custom-component>
,
尝试时,我在Angular编译器中遇到错误:
Can't bind to 'ngForTrackby' since it isn't a known property of 'custom-component'.
以这种方式循环自定义组件时,是否可以使用trackby
?