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}"

1 Answer 1

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}"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.