Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: third_party/pkg/angular/lib/directive/ng_style.dart

Issue 148453003: Updating Angular version (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 part of angular.directive; 1 part of angular.directive;
2 2
3 /** 3 /**
4 * The `ngStyle` directive allows you to set CSS style on an HTML element condi tionally. 4 * The `ngStyle` directive allows you to set CSS style on an HTML element condi tionally.
5 * 5 *
6 * @example 6 * @example
7 <span ng-style="{color:'red'}">Sample Text</span> 7 <span ng-style="{color:'red'}">Sample Text</span>
8 */ 8 */
9 @NgDirective( 9 @NgDirective(
10 selector: '[ng-style]', 10 selector: '[ng-style]',
11 map: const { 'ng-style': '@styleExpression'}) 11 map: const { 'ng-style': '@styleExpression'})
12 class NgStyleDirective { 12 class NgStyleDirective {
13 dom.Element _element; 13 dom.Element _element;
14 Scope _scope; 14 Scope _scope;
15 15
16 String _styleExpression; 16 String _styleExpression;
17 17
18 NgStyleDirective(this._element, this._scope); 18 NgStyleDirective(this._element, this._scope);
19 19
20 Function _removeWatch = () => null; 20 Function _removeWatch = () => null;
21 var _lastStyles; 21 var _lastStyles;
22 22
23 /** 23 /**
24 * ng-style attribute takes an expression hich evals to an 24 * ng-style attribute takes an expression which evaluates to an
25 * object whose keys are CSS style names and values are corresponding valu es for those CSS 25 * object whose keys are CSS style names and values are corresponding valu es for those CSS
26 * keys. 26 * keys.
27 */ 27 */
28 set styleExpression(String value) { 28 set styleExpression(String value) {
29 _styleExpression = value; 29 _styleExpression = value;
30 _removeWatch(); 30 _removeWatch();
31 _removeWatch = _scope.$watchCollection(_styleExpression, _onStyleChange); 31 _removeWatch = _scope.$watchCollection(_styleExpression, _onStyleChange);
32 } 32 }
33 33
34 _onStyleChange(Map newStyles) { 34 _onStyleChange(Map newStyles) {
35 dom.CssStyleDeclaration css = _element.style; 35 dom.CssStyleDeclaration css = _element.style;
36 if (_lastStyles != null) { 36 if (_lastStyles != null) {
37 _lastStyles.forEach((val, style) { css.setProperty(val, ''); }); 37 _lastStyles.forEach((val, style) { css.setProperty(val, ''); });
38 } 38 }
39 _lastStyles = newStyles; 39 _lastStyles = newStyles;
40 40
41 if (newStyles != null) { 41 if (newStyles != null) {
42 newStyles.forEach((val, style) { css.setProperty(val, style); }); 42 newStyles.forEach((val, style) { css.setProperty(val, style); });
43 } 43 }
44 } 44 }
45 } 45 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/directive/ng_src_boolean.dart ('k') | third_party/pkg/angular/lib/filter/limit_to.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698