在Angular中循环自定义组件时如何使用Trackby?

时间:2019-10-30 17:06:56

标签: angular

我正在为trackby:自定义组件循环提供*ngForThis 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

0 个答案:

没有答案