Class Binding and ngClass

Binding to the class attribute

Use class binding to add and remove CSS class names from an element’s class attribute.

Binding to a single CSS class

To create a single class binding, use the prefix class followed by a dot and the name of the CSS class. For example,

[class.sale]="onSale"
Was this page helpful?