6

我刚开始使用 Polymer 1.0 并尝试对集合进行非常简单的绑定。我能够在 dom-repeat 中显示文本,但双向绑定到 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>
4

1 回答 1

7

更改为:value="{{item.value::input}}" 请参见此处: http: //plnkr.co/edit/QWdCk7ReXxtdKndwPdqq

于 2015-06-10T15:00:37.700 回答