You can try this, like this example, by adding a color property to the object and changing the color property of this object when you click
<ion-list>
<ion-item *ngFor="let friend of friendsList">
<ion-avatar item-start>
<img src={{friend.img}}>
</ion-avatar>
<button ion-button color="rank" class="avat"> </button>
<h2>{{friend.name}}</h2>
<p>{{friend.status}}</p>
<button (click)="toggleNamedColor(friend)" ion-button round color="rank" [color]="friend.ionicNamedColor" item-end>+Add</button>
</ion-item>
</ion-list>
And in ts
public toggleNamedColor(friend): void {
if(friend.ionicNamedColor === 'rank') {
friend.ionicNamedColor = 'primary'
} else {
friend.ionicNamedColor = 'rank'
}
}
source
share