Change button icon when clicking :
I need to change button icon when clicking
What exactly should happen when what happens?
I need when clicking the button, the icon must change, as the images indicate, and the reverse
<button ion-button icon-left>
<ion-icon [name]="(isAdded) ? 'remove' : 'add'"></ion-icon>
Photo
</button>
isAdded = true/false in .ts
3 Likes
How declared isAdded ??
in .html
<button ion-button icon-left (click)="clickFunction()">
<ion-icon [name]="(isAdded) ? 'remove' : 'add'"></ion-icon>
Photo
</button>
in .ts
...
export class MainPage {
isAdded: boolean = false;
...
clickFunction() {
this.isAdded = !this.isAdded;
}
}