Adds and removes a set of HTML styles.
Setting inline styles with NgStyle
Use NgStyle to set multiple inline styles simultaneously, based on the state of the component.
- To use
NgStyle, add a method to the component class. In the following example,setCurrentStyles()sets the propertycurrentStyleswith an object that defines three styles, based on the state of three other component properties.
<div [ngStyle]="currentStyles"> This div is initially italic, normal weight, and extra large (24px). </div>