docs: add api doc for ng_style directive (#27379)

PR Close #27379
This commit is contained in:
Judy Bogart 2018-11-30 12:03:58 -08:00 committed by Alex Rickabaugh
parent e0fbe8611e
commit d73734dcb7

View File

@ -12,21 +12,34 @@ import {Directive, DoCheck, ElementRef, Input, KeyValueChanges, KeyValueDiffer,
* @ngModule CommonModule * @ngModule CommonModule
* *
* @usageNotes * @usageNotes
*
* Set the font of the containing element to the result of an expression.
*
* ``` * ```
* <some-element [ngStyle]="{'font-style': styleExp}">...</some-element> * <some-element [ngStyle]="{'font-style': styleExp}">...</some-element>
* ```
* *
* Set the width of the containing element to a pixel value returned by an expression.
*
* ```
* <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element> * <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>
* ```
* *
* Set a collection of style values using an expression that returns key-value pairs.
*
* ```
* <some-element [ngStyle]="objExp">...</some-element> * <some-element [ngStyle]="objExp">...</some-element>
* ``` * ```
* *
* @description * @description
* *
* Update an HTML element styles. * An attribute directive that updates styles for the containing HTML element.
* * Sets one or more style properties, specified as key-value pairs.
* The styles are updated according to the value of the expression evaluation: * The key is a style name, with an optional `.<unit>` suffix (such as 'top.px', 'font-style.em').
* - keys are style names with an optional `.<unit>` suffix (ie 'top.px', 'font-style.em'), * The value is an expression to be evaluated.
* - values are the values assigned to those properties (expressed in the given unit). * The resulting non-null value, expressed in the given unit,
* is assigned to the given style property.
* If the result of evaluation is null, the corresponding style is removed.
* *
* @publicApi * @publicApi
*/ */