Polymer dom中继器中的双向数据绑定
我试图在dom repeater和模板中的输入之间创建一个双向数据绑定,但更改似乎不会传播回来。我做错了什么Polymer dom中继器中的双向数据绑定,polymer,polymer-1.0,Polymer,Polymer 1.0,我试图在dom repeater和模板中的输入之间创建一个双向数据绑定,但更改似乎不会传播回来。我做错了什么 <dom-module id="record-card"> <template id="node"> <template is="dom-repeat" items="{{labels}}"> <h1> <input is="iron-input" bin
<dom-module id="record-card">
<template id="node">
<template is="dom-repeat" items="{{labels}}">
<h1>
<input is="iron-input" bind-value="{{item}}" on-change="labelsChanged">
</h1>
</template>
<input is="iron-input" bind-value="{{labels.0}}">
Labels: <span>{{labels}}</span>
</template>
</dom-module>
<script>
Polymer({
is: "record-card",
properties: {
labels: {
type: Array,
notify: true,
value: function() {
return ["Pizza", "Person"]
}
}
}
});
</script>
标签:{{Labels}}
聚合物({
是:“记录卡”,
特性:{
标签:{
类型:数组,
通知:正确,
值:函数(){
返回[“比萨饼”,“人”]
}
}
}
});
dom repeater中的输入不会传播,它外部的输入使用路径传播到repeater中,但不是相反,但它不会更新
{{}
我问了一个类似的问题(),我得到的答案是使用value=“{{item::input}}
。但是,似乎绑定到原始字符串数组的效果不太好。我尝试将其更改为具有单个字符串属性的对象数组,结果成功了
以下是我如何处理嵌套dom repeat中更改的数据
谢谢,是的,我试过对你的评论,但还不被允许。我会检查这是否有效…是的,我试过了,它只在对象时有效,所以这是序列化系列。谢谢。GitHub上的问题:
// Add Task to the selected Employee
_addTask: function() {
var i=this._getSelectedEmployeeIndex()
if (i>=0) {
var employee = this.employees[i]
// use both for child dom-repeat
this.push('employees.'+i+'.tasks', {name: this._random(this.__tasks)})
this.notifyPath('employees.'+i+'.tasks.*')
}
},