On this page
NgStyle
directive
| npm Package | @angular/common | 
|---|---|
| Module | import { NgStyle } from '@angular/common'; | 
     
| Source | common/src/directives/ng_style.ts | 
| NgModule | CommonModule | 
     
Overview
@Directive({ selector: '[ngStyle]' })
class NgStyle implements DoCheck {
  set ngStyle: {...}
  ngDoCheck()
}
  How To Use
<some-element [ngStyle]="{'font-style': styleExp}">...</some-element>
<some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>
<some-element [ngStyle]="objExp">...</some-element>
  Selectors
[ngStyle]
  Inputs
ngStyle bound to NgStyle.ngStyle
  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).
 
Constructor
constructor(_differs: KeyValueDiffers, _ngEl: ElementRef, _renderer: Renderer2)
  Members
set ngStyle: { [key: string]: string; }
  ngDoCheck()
  © 2010–2018 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
 https://v5.angular.io/api/common/NgStyle