简体   繁体   English

我如何更改单击ionic 2角上的颜色按钮

[英]how can i change color buttons on click ionic 2 angular

I tried to change the color of the button i click, but it change all the colors of the buttons of the list 我试图更改单击的按钮的颜色,但是它更改了列表中按钮的所有颜色

this is my code : 这是我的代码:

 ecardGroup(groupe) { if(this.hexColor === '#000000') { this.hexColor = '#dddddd' } else { this.hexColor = '#000000' } } 
  <ion-col col-9 class="sildes"> <ion-slides slidesPerView="{{nbPerPage}}" spaceBetween="5"> <ion-slide *ngFor="let slide of lesEboxs; let i = index"> <button ion-button block (click)="ecardGroup(slide)" class="currentGroup" [style.background-color]="hexColor"> <ion-icon class="warning" name="star" *ngIf="slide.nom_gr == 'Pro'"></ion-icon> {{slide.nom_gr}} </button> </ion-slide> </ion-slides> </ion-col> 

在您的课程上创建一个slideClicked属性,并像这样更改模板:

<button ion-button block [style.background-color]="(slide === this.slideClicked) ? '#000000' : '#dddddd'" (click)="this.slideClicked = slide" class="currentGroup">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM