Skip to content

Instantly share code, notes, and snippets.

@tejainece
Created April 12, 2014 14:18
Show Gist options
  • Select an option

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

Select an option

Save tejainece/10537899 to your computer and use it in GitHub Desktop.
Polymer.dart binding without custom elements. In this example, we will use models.
class CountNotifier extends ChangeNotifier {
int _count = 0;
int get count => _count;
set count(int count) {
_count = notifyPropertyChange(#count, _count, count);
}
}
CountNotifier counter = new CountNotifier();
templateBind(querySelector('#counter'))
..model = counter;
querySelector("#inc_count").onClick.listen((_) {
counter.count++;
});
<template id="counter" bind>
You have clicked {{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