當已經迭代了特定值時,Angular中不顯示*ngFor
中的元素的正確方法是什麼?我試着用一個新的數組來比較它,但是,當ngFor突然再次循環時,它很複雜。如何在特定值迭代時隱藏* ngFor中的元素
//方法
checkDateHeader(date) {
if (this.dateHeaders.indexOf(date) > -1) {
return false;
} else {
this.dateHeaders.push(date);
console.log(this.dateHeaders);
return true;
}
}
//模板
<section *ngFor="let key of todoBacklog | OrderByDate;">
<ion-list-header *ngIf="checkDateHeader(key.putInbacklogDate | date:'yMMMMEEEEd')">
{{key.putInbacklogDate | date:'yMMMMEEEEd'}}
</ion-list-header>
<ion-card>
<ion-item>
<button ion-button icon-left clear item-right>
<ion-icon name="md-more"></ion-icon>
</button>
</ion-item>
<ion-card-content>
<ion-card-title>
{{key.title}}
</ion-card-title>
</ion-card-content>
</ion-card>
</section>