我有一个服务的NgFor,我想用click事件创建一个标签。如果单击标签更改颜色。这是我的代码,但如果点击所有标签都会更改。
<ion-slide *ngFor="let plan of plans | slice:0:4; let i=index">
<ion-grid class="box-plan">
<ion-label [attr.id]="i" class="text-box-add"
(click)="addToCartPlans(plan)" >{{text}}</ion-label>
</ion-grid>
</ion-slide>
addToCartPlans(plan: any) {
let currentIndex = this.slides.getActiveIndex();
this.lines[currentIndex].noPlan = true;
this.hasPlans = this.lines[currentIndex].noPlan;
this.lines[currentIndex].plans = plan;
this.selected = true;
this.text = 'Selected';
}