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

fix(bind-*): zone.run scope.apply on bind- change events #1448

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions example/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<li><a href="paper.html">paper.html</a></li>
<li><a href="form.html">form.html</a></li>
<li><a href="maps.html">maps.html</a></li>
<li><a href="paper_radio_group.html">paper_radio_group.html</a></li>
</ul>
</body>
</html>
19 changes: 19 additions & 0 deletions example/web/paper_radio_group.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:angular/angular.dart';
import 'package:angular/application_factory.dart';

import 'dart:html';

@Component(
selector: 'cmp',
template: '<paper-radio-group bind-selected="cmp.insertOption"> <paper-radio-button name="asis" label="Insert as is"></paper-radio-button> <paper-radio-button name="duplicate" label="Insert as duplicate"></paper-radio-button> </paper-radio-group> {{cmp.insertOption}}',
publishAs: 'cmp'
)
class Cmp {
Object insertOption;
}

main() {
applicationFactory()
.addModule(new Module()..bind(Cmp))
.run();
}
20 changes: 20 additions & 0 deletions example/web/paper_radio_group.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<title>Paper radio group example</title>
<!-- 0. bower install; pub serve -->
<!-- 1. Load platform.js for polyfill support. -->
<script src="bower_components/platform/platform.js"></script>

<!-- 2. Use an HTML Import to bring in the element. -->
<link rel="import"
href="bower_components/paper-radio-group/paper-radio-group.html">
</head>
<body>
<cmp></cmp>
<!-- needed for the getter extractor -->
{{cmp}} {{insertOption}}
<script type="application/dart" src="paper_radio_group.dart"></script>
<script src="packages/browser/dart.js"></script>
</body>
</html>
15 changes: 10 additions & 5 deletions lib/core_dom/element_binder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,16 @@ class ElementBinder {
});

if (bindAssignableProps.isNotEmpty) {
node.addEventListener('change', (_) {
bindAssignableProps.forEach((propAndExp) {
propAndExp[1].assign(scope.context, jsNode[propAndExp[0]]);
});
});
// due to https://code.google.com/p/dart/issues/detail?id=17406
// we have to manually run the zone.
var zone = Zone.current;
node.addEventListener('change', (_) =>
zone.run(() =>
bindAssignableProps.forEach((propAndExp) =>
propAndExp[1].assign(scope.context, jsNode[propAndExp[0]])
)
)
);
}

if (onEvents.isNotEmpty) {
Expand Down
1 change: 1 addition & 0 deletions lib/core_dom/module_internal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import 'package:angular/directive/module.dart' show NgBaseCss;
import 'package:angular/core_dom/css_shim.dart' as cssShim;

import 'dart:collection';
import 'dart:async';

part 'animation.dart';
part 'cookies.dart';
Expand Down