un
Sintaxis:
<element [style.style-property] = "'style-value'">
HTML
<h1 [style.color] = "'green'" [style.text-align] = "'center'" > GeeksforGeeks </h1>
Producción:
la la
HTML
<div [style.color] = "'green'" [style.text-align] = "'center'" [style.font-size.px]="'24'" > GeeksforGeeks </div>
Producción:
HTML
<div [style.color]="status=='error' ? 'red': 'green'" [style.text-align] = "'center'" [style.font-size.px]="'24'" > GeeksforGeeks </div>
Javascript
import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { status = "All good"; }
Producción: