Skip to content

Instantly share code, notes, and snippets.

@ryanisinallofus
Created March 9, 2015 19:20
Show Gist options
  • Save ryanisinallofus/177b5e09a0fa5d63146f to your computer and use it in GitHub Desktop.
Save ryanisinallofus/177b5e09a0fa5d63146f to your computer and use it in GitHub Desktop.
<!-- Define element -->
<polymer-element name="my-counter" attributes="counter">
<template>
<style> /*...*/ </style>
<div id="label"><content></content></div>
Value: <span id="counterVal">{{counter}}</span><br>
<button on-tap="{{increment}}">Increment</button>
</template>
<script>
Polymer({
counter: 0, // Default value
counterChanged: function() {
this.$.counterVal.classList.add('highlight');
},
increment: function() {
this.counter++;
}
});
</script>
</polymer-element>
<!-- Use element -->
<my-counter counter="10">Points</my-counter>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment