我已将图标收藏夹添加到有角项目中,但是当我单击时,所有属性(项目)都会更改状态。 我的模板
<div *ngFor="let property of properties" class="col-md-6 col-lg-4 nopadding" >
..................
<div class="center_favorit">
<p class="rentSale">{{property['rentSale']}}</p>
<button mat-icon-button (click)="isFavorite($event, property)" [ngClass]="toggle? 'isFavorite' : 'isNotFavorite'">
<mat-icon aria-label="icon favorite">favorite</mat-icon>
</button>
</div>
和我的component.ts
toggle = true;
isFavorite(event, newProperty) {
console.log(this.properties);
this.toggle = !this.toggle;
}
您是否有最简单的方法在每个项目上添加一个收藏夹图标,当我单击该图标时,它会更改状态(例如:它变为黄色),并且我会在后端访问此状态值。