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: {[key
  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
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: Renderer)
  Members
set ngStyle: {[key
  ngDoCheck()
  © 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
 https://v4.angular.io/api/common/NgStyle