Skip to content

Commit 6596c72

Browse files
pkozlowski-opensourcetbosch
authored andcommitted
docs(NgStyle): add documentation
Closes angular#2931
1 parent f1f5784 commit 6596c72

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

modules/angular2/src/directives/ng_style.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,29 @@ import {KeyValueChanges} from 'angular2/src/change_detection/pipes/keyvalue_chan
66
import {isPresent, print} from 'angular2/src/facade/lang';
77
import {Renderer} from 'angular2/src/render/api';
88

9+
/**
10+
* Adds or removes styles based on an {expression}.
11+
*
12+
* When the expression assigned to `ng-style` evaluates to an object, the corresponding element
13+
* styles are updated. Style names to update are taken from the object keys and values - from the
14+
* corresponding object values.
15+
*
16+
* # Example:
17+
*
18+
* ```
19+
* <div ng-style="{'text-align': alignEpr}"></div>
20+
* ```
21+
*
22+
* In the above example the `text-align` style will be updated based on the `alignEpr` value
23+
* changes.
24+
*
25+
* # Syntax
26+
*
27+
* - `<div ng-style="{'text-align': alignEpr}"></div>`
28+
* - `<div ng-style="styleExp"></div>`
29+
*
30+
* @exportedAs angular2/directives
31+
*/
932
@Directive({selector: '[ng-style]', lifecycle: [onCheck], properties: ['rawStyle: ng-style']})
1033
export class NgStyle {
1134
_pipe: Pipe;

0 commit comments

Comments
 (0)