3

I have an ngClass conditional that functions fine on class names without spaces, but when i try to do something like below and i toggle isTrue on button click, the class changes from "btn btn-primary" to "btn-default". The space in there seems to be throwing it off. Am i missing something

[ngClass]="{ 'btn btn-default': isTrue, 'btn btn-primary': !isTrue}"
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
Monzingo
  • 391
  • 1
  • 7
  • 17

1 Answers1

9

Take the common one out, and have the rest of the expression in an ngClass directive

class="btn" [ngClass]="{ 'btn-default': isTrue, 'btn-primary': !isTrue}"
0mpurdy
  • 3,198
  • 1
  • 19
  • 28
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299