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

Commit 51ee329

Browse files
vicbmhevery
authored andcommitted
fix(ng-style): watch in RO mode
Closes #721
1 parent 9a92b5c commit 51ee329

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/directive/ng_style.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ part of angular.directive;
99
*/
1010
@NgDirective(
1111
selector: '[ng-style]',
12-
map: const { 'ng-style': '@styleExpression'})
12+
map: const {'ng-style': '@styleExpression'})
1313
class NgStyleDirective {
1414
final dom.Element _element;
1515
final Scope _scope;
@@ -28,18 +28,19 @@ class NgStyleDirective {
2828
set styleExpression(String value) {
2929
_styleExpression = value;
3030
if (_watch != null) _watch.remove();
31-
_watch = _scope.watch(_parser(_styleExpression, collection: true), _onStyleChange);
31+
_watch = _scope.watch(_parser(_styleExpression, collection: true),
32+
_onStyleChange, readOnly: true);
3233
}
3334

3435
_onStyleChange(MapChangeRecord mapChangeRecord, _) {
3536
if (mapChangeRecord != null) {
3637
dom.CssStyleDeclaration css = _element.style;
37-
fn(MapKeyValue kv) => css.setProperty(kv.key, kv.currentValue == null ? '' : kv.currentValue);
38+
fn(MapKeyValue m) =>
39+
css.setProperty(m.key, m.currentValue == null ? '' : m.currentValue);
3840

39-
mapChangeRecord
40-
..forEachRemoval(fn)
41-
..forEachChange(fn)
42-
..forEachAddition(fn);
41+
mapChangeRecord..forEachRemoval(fn)
42+
..forEachChange(fn)
43+
..forEachAddition(fn);
4344
}
4445
}
4546
}

0 commit comments

Comments
 (0)