Skip to main content

angular - How to bind style

app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})

export class AppComponent {
  color:String = "indigo";
}
app.component.html

<h2>Angular Style Binding</h2>

<h3 [style.color]="color">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    Phasellus sit amet dignissim justo, vitae maximus lectus.
    Integer molestie a nunc id ullamcorper.
    Etiam ornare est quis rhoncus maximus.
</h3>
More Angular tutorials