-1

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()"> 
aria08
  • 21
  • 3

2 Answers2

1

You can do this

<div [ngClass]="{'class1': getClass1(), 'class2': getClass2()}">
</div>

With getClass1() and getClass2() returning true or false to conditionally apply class1, class2.

cybering
  • 778
  • 7
  • 19
0

This worked for me

[ngClass]=['getSomeClass()', policyNumber.length<=0 ? 'white-background' : '']
aria08
  • 21
  • 3