Skip to content

Instantly share code, notes, and snippets.

@tejainece
Created April 12, 2014 13:59
Show Gist options
  • Select an option

  • Save tejainece/10537085 to your computer and use it in GitHub Desktop.

Select an option

Save tejainece/10537085 to your computer and use it in GitHub Desktop.
Polymer.dart bindings without custom element. In this example, we will only bind using binding delegates.
class CountNotifier extends ChangeNotifier {
int _count = 0;
int get count => _count;
set count(int count) {
_count = notifyPropertyChange(#count, _count, count);
}
}
CountNotifier counter = new CountNotifier();
Map globals = {
"count": counter,
};
templateBind(querySelector('#counter'))
..bindingDelegate = new PolymerExpressions(globals: globals);
querySelector("#inc_count").onClick.listen((_) {
counter.count++;
});
<template id="counter" bind>
You have clicked {{count.count}} times.
</template>
<input type="button" id="inc_count" value="Count">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment