I have a situation I can't figure out. ng-class is applying both of these classes, even though the expressions specify inverse logic. Here's the code that expresses how I want the classes to work: either isThinking or notThinking, but never both:
<div class="myWidget" ng-class="{
isThinking: vm.isThinking(),
notThinking: !vm.isThinking()
}"
</div>
The problem is that Angular applies both classes. I can't understand why.
I have investigated:
$digestcycle just needs to be triggered? No, causing a digest has no effect- Does
isThinkingalways return true or false, never undefined? confirmed. - Does changing the name of one of the classes from
notThinkingtoisReadysolve it? (testing for perhaps a too-fuzzy regex match) No, the classes still are both active at the same time. - Does removing the second
notThinkingexpression altogether cause theisThinkingclass to be properly added and removed? Yes, yes it does. Why is that, I have no idea.
Angular version is 1.4.6.
Can anyone think of a reason why both classes would be active, when the 2 expressions are clearly inverse?