ZoM
ZoM

Reputation: 516

Change part of the CSS class using ngClass

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!

Upvotes: 0

Views: 84

Answers (1)

Fourth
Fourth

Reputation: 9351

<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.

Upvotes: 1

Related Questions