This is the archived documentation for Angular v6. Please visit angular.io to see documentation for the current version of Angular.

NgStyle

Update an HTML element styles.

See more...

NgModule

Selectors

Properties

Property Description
@Input()
ngStyle: { [key: string]: string; }
Write-only.

Description

The styles are updated according to the value of the expression evaluation:

  • keys are style names with an optional .<unit> suffix (ie 'top.px', 'font-style.em'),
  • values are the values assigned to those properties (expressed in the given unit).
<some-element [ngStyle]="{'font-style': styleExp}">...</some-element> <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element> <some-element [ngStyle]="objExp">...</some-element>
      
      <some-element [ngStyle]="{'font-style': styleExp}">...</some-element>

<some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>

<some-element [ngStyle]="objExp">...</some-element>
    

Methods

ngDoCheck()
      
      ngDoCheck()
    

Parameters

There are no parameters.