I want to use multiple classes inside Angular [ngClass]. I have two classes, It should work accordingly as per the condition of the flag, that are already passed from the component.ts.
You can do like this [ngClass]="{'class1':condition1, 'class2':condition2}" .
Yes it does, I just had to use ! important in css to make it visible.
Combining NgStyle and NgClass Directives with our knowledge of Angular Template Syntax, we can marry conditional styling with Angular's Property & Event Binding.
Do like this:
<div [ngClass]="condition ? 'class1' : 'class2' " ></div>
(Ternary Operator Usage)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With