How to change icon when clicked in list item? (SOLVED)


#1

Hi All.

At first, you can look at my codepen : http://codepen.io/harked/pen/gpvdNK
I want to create an event :
when user click the (+) button icon at the right, it will immediately change itself to (-) button icon.
And when we click it again, it will be back to (+).

It seems like the changing-icon happened in accordion list : http://codepen.io/ionic/pen/uJkCz
But i got a problem how to implement that in my case.

is there anyone can show how to create like that?
Any advice would be greatly appreciated!

Thanks.


#2

I didn’t realise I was doing it, but I think I’ve actually just overwritten your codepen with the solution!


#3

Wew. That’s cool!
Great thanks @CT14_IT :wink:

But what if it also can change the icon color?
from green to red (or “balanced” to “assertive” -in Ionic) and vice versa.
Is there any way to create like that?


#4

Yeah, you’ll see that I change the class of the button between ion-plus-circled and ion-minus-circled, you can do the same with button-balanced and button-assertive too (which I’ve now done to the codepen)


#5

Cool! I understand now.
Thanks (again) @CT14_IT !