{ "id": "api/common/NgStyle", "title": "NgStyle", "contents": "\n\n
\n
\n
\n \n API > @angular/common\n
\n \n
\n \n
\n

NgStylelink

\n \n \n \n \n \n
\n \n \n\n
\n \n
\n

An attribute directive that updates styles for the containing HTML element.\nSets one or more style properties, specified as colon-separated key-value pairs.\nThe key is a style name, with an optional .<unit> suffix\n(such as 'top.px', 'font-style.em').\nThe value is an expression to be evaluated.\nThe resulting non-null value, expressed in the given unit,\nis assigned to the given style property.\nIf the result of evaluation is null, the corresponding style is removed.

\n\n \n
\n \n \n \n \n\n

NgModulelink

\n\n\n\n \n
\n

Selectorslink

\n \n \n \n
\n\n\n\n \n\n
\n

Propertieslink

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
PropertyDescription
\n \n @Input()
ngStyle: { [klass: string]: any; }
\n
Write-Only\n \n \n \n
\n
\n\n\n\n \n\n\n \n
\n

Descriptionlink

\n \n

Set the font of the containing element to the result of an expression.

\n\n<some-element [ngStyle]=\"{'font-style': styleExp}\">...</some-element>\n\n

Set the width of the containing element to a pixel value returned by an expression.

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

Set a collection of style values using an expression that returns key-value pairs.

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

Methodslink

\n \n \n\n \n \n \n \n \n \n \n \n\n \n\n \n \n
\n
\n

\n ngDoCheck()\n \n link

\n \n
\n
\n
\n \n\n ngDoCheck()\n\n \n\n
Parameters
\n

There are no parameters.

\n\n \n\n\n \n\n \n
\n
\n\n \n
\n\n \n \n \n\n
\n
\n\n\n" }