我刚开始玩 Polymer 1.0,正在尝试对集合进行非常简单的绑定(bind)。我能够在 dom-repeat 中显示文本,但是 two-way 绑定(bind)到 iron-input 不起作用。 我尝试了字符串数组和对象。运气不好。
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/iron-input/iron-input.html">
<dom-module id="hello-world">
<template>
<ul>
<template is="dom-repeat" items="{{data}}">
<li>{{item.value}}</li>
</template>
</ul>
<ul>
<template is="dom-repeat" items="{{data}}">
<li><input is="iron-input" bind-value="{{item.value}}"></input></li>
</template>
</ul>
</template>
</dom-module>
<script>
Polymer({
is: "hello-world",
ready: function() {
this.data = [
{ value: "Hello" },
{ value: "World!" }
];
}
});
</script>
最佳答案
更改为:value="{{item.value::input}}"
看这里:http://plnkr.co/edit/QWdCk7ReXxtdKndwPdqq
关于javascript - 如何将 iron-input 双向绑定(bind)到 dom-repeat 的项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30748691/