尝试了所有我能猜到的语法都不能让它工作!
<!--- THIS WORKS FINE --->
<ion-card *ngFor="#post of posts">
{{post|json}}
</ion-card>
<!--- BLANK PAGE --->
<ion-card *ngFor="#post of posts track by post.id">
{{post|json}}
</ion-card>
<!--- Exception : Cannot read property 'id' of undefined --->
<ion-card *ngFor="#post of posts;trackBy:post.id">
{{post|json}}
</ion-card>
<!--- Exception : Cannot read property 'undefined' of undefined --->
<ion-card *ngFor="#post of posts;trackBy:posts[index].id">
{{post|json}}
</ion-card>
<!--- Blank page no exception raised ! --->
<ion-card *ngFor="#post of posts;#index index;trackBy:posts[index].id">
{{post|json}}
</ion-card>
对我有用的唯一方法是
在控制器类中创建方法
识别(索引,发布:发布){ 返回 post.id }
和
<ion-card *ngFor="#post of posts;trackBy:identify">
</ion-card>
这是唯一的方法吗?我不能只为 trackBy 指定一个属性名称吗?