Search code examples
javascriptangularjsng-class

How to use ng-class binding one more class to one value


I want to bind one more class to a value, like this:

ng-class="{first: isTrue, second: isTrue, third: isTrue}"

Is ng-class Exists any usage can bind them in once, like this? (below code is not working)

ng-class="{[first, second, third]: isTrue}"

Solution

  • It turns out that property name in the single quotes will directly be added to the class when value is true.

    ng-class="{'first second third': isTrue}"
    

    works.