If I have something like this
<div ng-class="{'breakfast': meal == 'eggs'}"></div> Now I need to create a directive that would add the same thing, so doing this:
restrict: 'C' scope: meal:"&" link:(scope, element, attr)-> element.attr('ng-class', "{'breakfast': meal == 'eggs'}") adds the attribute to the DOM, but then nothing happens, when meal == 'eggs' it doesn't add breakfast class to the element. What am I doing wrong?
ps. I can of course do it with element.addClass and element.removeClass but then the animation would only work when I add the class, but wouldn't for the removal (if I have css styles like .breakfast-add, .breakfast-remove etc.
'='rather than'&','&'is for passing functionng-class="{'breakfast... etc.all the time. Ended up using$animate.addClass, but the question itself remains open