Reputation: 21
Can we add two ng-class in one div? If so then how to write it. How can we write this together?
Thank you in advance.
<div [ngClass]={'white-background': policy number.length <=0}
[ngClass]="getSomeClass()">
Upvotes: -1
Views: 627
Reputation: 21
This worked for me
[ngClass]=['getSomeClass()', policyNumber.length<=0 ? 'white-background' : '']
Upvotes: 0
Reputation: 998
You can do this
<div [ngClass]="{'class1': getClass1(), 'class2': getClass2()}">
</div>
With getClass1()
and getClass2()
returning true
or false
to conditionally apply class1, class2.
Upvotes: 1