Question

I have multiple classes apply to an element. Is it possible to change only 1 class, not the all of the classes?

For example,

<span ng-class="{'result warning' : error, 'result passing' : !error}"></span>

As you can see, I have to duplicate result class in both of the conditions. Is there a way to not have to repeat it?

Thanks!

Was it helpful?

Solution

<span class="result" ng-class="{'warning': error, 'passing': !error}"></span>

ng-class can add/remove classes - it doesn't over-write existing classes unless they are specified in ng-class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top