When interpolated class attribute changes, classes from ng-class are not merged in #1016
Description
Open http://jsfiddle.net/ADukg/224/
Set ngclass to true by clicking the first button. Note how the ngclass text turns green.
Then set class to true by clicking the second button. Note how the ngclass text turned red again.
So:
Result: div element has class="static class"
, thus coloring "class" green and "ngclass" red
Expected result: div element has class="static class ngclass"
, thus coloring both "class" and "ngclass" green
I have a (maybe very ugly) fix for this, which involves:
- Not setting
attr[name]
toundefined
whenname === 'class'
inaddAttrInterpolateDirective()
$watch
:ing$interpolate(attr['class'])
inclassDirective()
and reapplying the "ngclasses" when it changes.
The reason I'm not totally sure about this solution is that I don't know why you're setting attributes to undefined
in addAttrInterpolateDirective()
, and I'm not sure what consequences it will have if we don't.
What do you think about this?
I can post some more code later, but I want to see if all tests pass first.