Changing ion-icon dynamically on click/select -


#1

I am new to ionic native and basically trying to change the particular icon from the list of icons, in my case on click of toggle all the icons are changing. - Here is my code
Need more of Ionic solution for the problem i am facing.

HTML-

<ion-card *ngFor=“let post of posts”>






{{post.bookname}}


{{post.price}}





<button ion-button clear small color=“danger” icon-start (click)=‘toggle(this)’>
<ion-icon [name]=“visible ? ‘heart’ : ‘heart-outline’”> - Here i am changing the icon



TS -

visible: boolean;
toggle(){
this.visible = !this.visible;
}


#2

If you are saying you want to track visibility separately for each post, you must make it a property of the post, not of the page.


#3

@rapropos Thank you for the reply,any working code pls share the fiddle or URL ?