How to set conditional classes in Angular?

You can set the class of an element dynamically using ngClass directive.

[ngClass]="{'red': a < 5 , 'blue' : a > 10}"

From the above code, class red or blue will be set if the conditions are satisfied. If both the conditions are satisfied, then the element is assigned both the classes.