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

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

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 4 * The `ngStyle` directive allows you to set CSS style on an HTML element
5 * conditionally. 5 * conditionally.
6 * 6 *
7 * @example 7 * @example
8 * <span ng-style="{color:'red'}">Sample Text</span> 8 * <span ng-style="{color:'red'}">Sample Text</span>
9 */ 9 */
10 @NgDirective( 10 @Decorator(
11 selector: '[ng-style]', 11 selector: '[ng-style]',
12 map: const { 'ng-style': '@styleExpression'}) 12 map: const {'ng-style': '@styleExpression'})
13 class NgStyleDirective { 13 class NgStyle {
14 final dom.Element _element; 14 final dom.Element _element;
15 final Scope _scope; 15 final Scope _scope;
16 final AstParser _parser;
17 16
18 String _styleExpression; 17 String _styleExpression;
19 Watch _watch; 18 Watch _watch;
20 19
21 NgStyleDirective(this._element, this._scope, this._parser); 20 NgStyle(this._element, this._scope);
22 21
23 /** 22 /**
24 * ng-style attribute takes an expression which evaluates to an 23 * ng-style attribute takes an expression which evaluates to an
25 * object whose keys are CSS style names and values are corresponding values 24 * object whose keys are CSS style names and values are corresponding values
26 * for those CSS keys. 25 * for those CSS keys.
27 */ 26 */
28 set styleExpression(String value) { 27 set styleExpression(String value) {
29 _styleExpression = value; 28 _styleExpression = value;
30 if (_watch != null) _watch.remove(); 29 if (_watch != null) _watch.remove();
31 _watch = _scope.watch(_parser(_styleExpression, collection: true), _onStyleC hange); 30 _watch = _scope.watch(_styleExpression, _onStyleChange, collection: true,
31 canChangeModel: false);
32 } 32 }
33 33
34 _onStyleChange(MapChangeRecord mapChangeRecord, _) { 34 _onStyleChange(MapChangeRecord mapChangeRecord, _) {
35 if (mapChangeRecord != null) { 35 if (mapChangeRecord != null) {
36 dom.CssStyleDeclaration css = _element.style; 36 dom.CssStyleDeclaration css = _element.style;
37 fn(MapKeyValue kv) => css.setProperty(kv.key, kv.currentValue == null ? '' : kv.currentValue); 37 fn(MapKeyValue m) =>
38 css.setProperty(m.key, m.currentValue == null ? '' : m.currentValue);
38 39
39 mapChangeRecord 40 mapChangeRecord..forEachRemoval(fn)
40 ..forEachRemoval(fn) 41 ..forEachChange(fn)
41 ..forEachChange(fn) 42 ..forEachAddition(fn);
42 ..forEachAddition(fn);
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/directive/ng_switch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698