Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
fix(ng-style): watch in RO mode
Browse files Browse the repository at this point in the history
Closes #721
  • Loading branch information
vicb authored and mhevery committed Mar 13, 2014
1 parent 9a92b5c commit 51ee329
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/directive/ng_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ part of angular.directive;
*/
@NgDirective(
selector: '[ng-style]',
map: const { 'ng-style': '@styleExpression'})
map: const {'ng-style': '@styleExpression'})
class NgStyleDirective {
final dom.Element _element;
final Scope _scope;
Expand All @@ -28,18 +28,19 @@ class NgStyleDirective {
set styleExpression(String value) {
_styleExpression = value;
if (_watch != null) _watch.remove();
_watch = _scope.watch(_parser(_styleExpression, collection: true), _onStyleChange);
_watch = _scope.watch(_parser(_styleExpression, collection: true),
_onStyleChange, readOnly: true);
}

_onStyleChange(MapChangeRecord mapChangeRecord, _) {
if (mapChangeRecord != null) {
dom.CssStyleDeclaration css = _element.style;
fn(MapKeyValue kv) => css.setProperty(kv.key, kv.currentValue == null ? '' : kv.currentValue);
fn(MapKeyValue m) =>
css.setProperty(m.key, m.currentValue == null ? '' : m.currentValue);

mapChangeRecord
..forEachRemoval(fn)
..forEachChange(fn)
..forEachAddition(fn);
mapChangeRecord..forEachRemoval(fn)
..forEachChange(fn)
..forEachAddition(fn);
}
}
}

0 comments on commit 51ee329

Please sign in to comment.