ngClass
ngClass
is an attribute directive used to modify the attributes of existing DOM elements- Use
ngClass
to add or remove multiple classes - Binding
ngClass
to an expression - An object with 1 or more key value pairs.
- Each key represents the CSS class, and the value determines the class should be rendered or not
- Key should be in single quote
<span [ngClass]="{
'glyphicon-star': isSelected,
'glyphicon-star-empty': !isSelected
}"></span>