Skip to content

Instantly share code, notes, and snippets.

@naderio
Created July 18, 2015 04:42
Show Gist options
  • Save naderio/f9ce485ec83b76a5fcdb to your computer and use it in GitHub Desktop.
Save naderio/f9ce485ec83b76a5fcdb to your computer and use it in GitHub Desktop.
Recreature and reattache custom elements depending on state property' value
<dom-module id="test-app">
<style>
:host {
display: block;
}
</style>
<template>
...
<template is="dom-if" if="{{isState(state, 'home')}}" restamp="true">
<feed-view count="{{count}}"></feed-view>
</template>
...
</template>
</dom-module>
<script>
Polymer({
is: 'test-app',
properties: {
state: {
type: String,
value: 'home'
},
count: {
type: Number,
value: 5
},
},
isState: function(state, value) {
return state === value;
},
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment