如何双向绑定铁输入到dom-repeat的项目? [英] How to two-way bind iron-input to dom-repeat's item?

查看:54
本文介绍了如何双向绑定铁输入到dom-repeat的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始玩Polymer 1.0,我正在尝试对集合进行非常简单的绑定。我能够在dom-repeat中显示文本,但双向绑定到铁输入不起作用。
我尝试了一系列字符串和对象。没有运气。

I just started playing with Polymer 1.0 and am trying to do a very simple binding to collection. I am able to display text within dom-repeat, but the two-way binding to iron-input does not work. I tried array of strings, and objects. No luck.

<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

这篇关于如何双向绑定铁输入到dom-repeat的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆