我尝试使用以下polymer's
template repeat
功能将自定义子元素绑定到本地存储的值:
<polymer-element name="aw-outerElement">
<template>
<template repeat="{{group in grouplist}}">
<aw-innerElement groupId="{{group.groupId}}" name="{{group.name}}" val="{{group.val}}"></aw-innerElement>
</template>
</template>
<script>
Polymer('aw-outerElement', {
ready : function () {
// Binding the project to the data-fields
this.prj = au.app.prj;
this.grouplist = [
{ groupId: 100, name: 'GroupName1', val: this.prj.ke.groupVal100},
{ groupId: 200, name: 'GroupName2', val: this.prj.ke.groupVal200}
];
}
</script>
在上面的代码中,我尝试通过属性传递数据绑定this.prj.ke.groupVal100
和this.prj.ke.groupVal200
我的内部元素。这是一个自定义元素,其中 value 属性应设置为例如。似乎只会设置存储的初始值0而不是value 属性内的数据绑定字符串 。有没有办法与内部元素进行数据绑定?aw-innerElement
val
aw-innerElement
paper-input
this.prj.ke.groupVal100
this.prj.ke.groupVal100
template repeat
我的内部元素如下所示:
<polymer-element name="aw-innerElement" attributes="groupId name val">
<template>
<paper-input type="number" floatingLabel label="{{groupId}} {{name}}" value="{{val}}" error="{{i18nnrerror}}"></paper-input>
</template>
<script>
Polymer('aw-innerElement', {
publish: {
groupId: 0,
name: '',
val: 0
},
ready : function () {
// Binding the project to the data-fields
this.prj = au.app.prj;
...
}
</script>
正如您在上面看到的value="{{val}}"
,我的 innerElement 应该设置为this.prj.ke.groupVal100
and this.prj.ke.groupVal200
。
提前致谢!