I have this code
<div *ngFor="let d of getDays(); let i = index" class="day hr left" (click)="pick(d, h)" [class.white]="days[d].indexOf(h) > -1">
</div>
It works fine but my question is how do I add another class name in this part [class.white]="days[d].indexOf(h) > -1"
? I have another class called .redborder{border 1px solid red}
. I tried this but didn't work [class.white.redborder]="days[d].indexOf(h) > -1"
. What else am I supposed to do?
You can use the ngClass
directive:
<element [ngClass]="{'white redborder' : days[d].indexOf(h) > -1}"></element>
For elseif
I guess you can use this:
<element [ngClass]="days[d].indexOf(h) > -1 ? 'white' : 'redborder'"></element>
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