⊗jsagPmStSES 49 of 97 menu

Binding CSS styles to a tag in Angular

We can also set a specific set of styles for an HTML element. This is done using the ngStyle directive. An object with CSS properties and their values ​​should be passed to this directive.

Let's try:

<div [ngStyle]="{'color': 'red', 'font-size': '20px'}"> text </div>

Given object:

export class AppComponent { public obj = { color: red, fontSize: '30px', fontWeight: 'bold' } }

Style any tag using this object.

azbydeenesfrkakkptruuz