Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
}