I want to implement a page containing a paper-tabs, with each tab showing a list of items according to the name initial. I wonder what is the best way for data-binding.
Also I have some trouble to access the data in the nested template. When I tap different tabs, it is not working as I expect.
Here is the simplified code:
//page
<paper-tabs selected="{{tab}}">
<template repeat="{{inital in pagination}}">
<paper-tab name="{{initial}}">
{{initial}}
</paper-tab>
</template>
</paper-tabs>
<items-field
tab="{{tab}}"
items="{{items}}">
</items-field>
//items-field
<polymer-element name="items-field" attributes="tab items">
<template>
<h2>h2 {{tab}}</h2>
<div>some other stuffs</div>
<template bind="{{items}}">
<h3>h3 {{tab}}</h3> <-- {{tab}} is undefined
<item-list
initial="{{tab}}"
</item-list>
</template>
</template>
<script>
Polymer({
tab: 'A'
)}
</script>
</polymer-element>
//item-list
<polymer-element name="items-list" attributes="initial">
<template>
<template repeat="{{item in items}}">
<item
hidden?="{{toHide(initial, item.name)}}">
</item>
</template>
</template>
<script>
Polymer({
ready: function () {
this.items = this.templateInstance.model;
console.log(this.initial); // <-- undefined
},
toHide: function (initial, name) {
if (initial === undefined ||
initial === name.charAt(0)) {
return false;
}
return true;
}
});
</script>
</polymer-element>