Skip to content

Commit bb8f627

Browse files
AJCraddockRichardLitt
authored andcommitted
docs(ngStyle): clarify using styles that are not valid property names
Closes angular#6838
1 parent 1048ebf commit bb8f627

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/ng/directive/ngStyle.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@
99
* The `ngStyle` directive allows you to set CSS style on an HTML element conditionally.
1010
*
1111
* @element ANY
12-
* @param {expression} ngStyle {@link guide/expression Expression} which evals to an
13-
* object whose keys are CSS style names and values are corresponding values for those CSS
14-
* keys.
12+
* @param {expression} ngStyle
13+
*
14+
* {@link guide/expression Expression} which evals to an
15+
* object whose keys are CSS style names and values are corresponding values for those CSS
16+
* keys.
17+
*
18+
* Since some CSS style names are not valid keys for an object, they must be quoted.
19+
* See the 'background-color' style in the example below.
1520
*
1621
* @example
1722
<example>
1823
<file name="index.html">
19-
<input type="button" value="set" ng-click="myStyle={color:'red'}">
24+
<input type="button" value="set color" ng-click="myStyle={color:'red'}">
25+
<input type="button" value="set background" ng-click="myStyle={'background-color':'blue'}">
2026
<input type="button" value="clear" ng-click="myStyle={}">
2127
<br/>
2228
<span ng-style="myStyle">Sample Text</span>
@@ -30,9 +36,9 @@
3036
<file name="protractor.js" type="protractor">
3137
var colorSpan = element(by.css('span'));
3238
33-
it('should check ng-style', function() {
39+
iit('should check ng-style', function() {
3440
expect(colorSpan.getCssValue('color')).toBe('rgba(0, 0, 0, 1)');
35-
element(by.css('input[value=set]')).click();
41+
element(by.css('input[value=\'set color\']')).click();
3642
expect(colorSpan.getCssValue('color')).toBe('rgba(255, 0, 0, 1)');
3743
element(by.css('input[value=clear]')).click();
3844
expect(colorSpan.getCssValue('color')).toBe('rgba(0, 0, 0, 1)');

0 commit comments

Comments
 (0)