angularng-classangular-ng-class

How can we write two ngClass in one div?


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()"> 

Solution

  • You can do this

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

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