How can I dynamically change the color of an icon when clicked?
Would using ngClass
be the most efficient approach for this task?
Currently, I have assigned a class to my icon.
<ion-card>
<ion-row>
<ion-col>
<button ion-button icon-left clear small>
<ion-icon name="eye" #name [ngClass]="{
'isActive' : isActive}" (click)="activeCheck(name)">
</ion-icon>
</button>
</ion-col>
</ion-row>
</ion-card>
.ts file
export class NewsPage implements OnInit {
isActive: boolean = false;
activeCheck(name) {
console.log(name);
this.isActive = !this.isActive;
}
}