我正在学习聚合物而且我遇到了一个问题,我有一个核心列表迭代数据源,模板化了一个带有核心图标按钮的纸质项目。
<core-list id="list" fit>
<template>
<paper-item flex class="row {{ {selected: selected} | tokenList }}">
<core-icon-button id="settings"
icon="settings"
on-tap={{settingTap}}>
</core-icon-button>
{{model.Name}}
</paper-item>
</template>
</core-list>
我遇到的问题是,在按钮的按键功能上,我需要父项的模型。是否采用“聚合方式”来完成我所描述的内容?或者我必须扩展
答案 0 :(得分:0)
<polymer-element name='cust-list'>
<template>
<style>
</style>
<core-list id="list" fit data={{models}}>
<template>
<paper-item flex class="row {{ {selected: selected} | tokenList }}">
<core-icon-button id="settings" icon="settings" on-tap={{settingTap}}></core-icon-button>
{{model.name}}
</paper-item>
</template>
</core-list>
</template>
<script>
Polymer('cust-list', {
models: [{name: "test1"}, {name: "test2"}],
settingTap: function(e,d,s) {
console.log(s.templateInstance.model.model);
}
});
</script>
</polymer-element>
<cust-list></cust-list>