Ionic option button directive not working on first click

In my list items, I am using an ionic option button with an icon that toggles on and off via a directive. The issue is that after I slide to review the option button, it takes two clicks to initially toggle the heart icon from off to on. How can I make it so that it will toggle on the first click? Please help.

Codepen: http://codepen.io/anon/pen/WQgLLJ

the directive does that what you have implemented… look closely:

var currentState = true;
if(currentState === true) {
  angular.element(elem).removeClass(attrs.onIcon);
  angular.element(elem).addClass(attrs.offIcon);
}

First time --> you remove the onIcon and add the classe offIcon, because currentState is true after you initialization :wink: