Toggle through styles with logic attached

i have list entries that each include a button, i want to use that button to toggle styles for the list entry its attached to and do some logic depending on the previous state

how do i best do this? one directive which switches the previous state and adds style + invokes function for logic? i havent used a directive with controller/logic yet so i have no idea how i split that best

thank you

It depends on how complex you need it to be. You might just want a simple ng-class without a directive.

However, if you need something a little more complex, you could look at this sample : http://codepen.io/calendee/pen/rJEhq

NOTE: The sample does NOT work in CodePen. You’ll need to put it in a local environment. I don’t know why classes aren’t applied in CodePen.