简体   繁体   English

聚合物铁-阿贾克斯对重复模板中纸件的结合值

[英]Polymer iron-ajax binding value to paper-item in repeat template

I am trying to get data from an URL and bind to a paper-dropdown-menu.我正在尝试从 URL 获取数据并绑定到纸张下拉菜单。 The following code is working:以下代码正在运行:

<template is="dom-bind">
    <paper-dropdown-menu id='ddl-node' label="Select Node">
        <paper-listbox class="dropdown-content" attr-for-selected="data-val">
            <template is="dom-repeat" items="{{data}}" as="item">
                <paper-item value="100">{{index}} - {{item.id}} - {{item.name}}</paper-item>
            </template>
        </paper-listbox>
    </paper-dropdown-menu>
    <iron-ajax id="ajax-node" url="site/get-data" handle-as="json" last-response="{{data}}" ></iron-ajax>
</template>

It could bind all data to content of paper-item as below:它可以将所有数据绑定到 paper-item 的内容,如下所示:

<paper-item value="100">0 - 100 - Item 1</paper-item>
<paper-item value="100">1 - 103 - Item 2</paper-item>

I bind {item.id} to attribute id of paper-item as following.我将{item.id}绑定到paper-item属性id如下。 It is also working:它也在工作:

<paper-item id="{{item.id}}">{{index}} - {{item.id}} - {{item.name}}</paper-item>

The results:结果:

<paper-item id="100">0 - 100 - Item 1</paper-item>
<paper-item id="103">1 - 103 - Item 2</paper-item>

I want to bind {item.id} to attribute value of paper-item as following.我想将{item.id}绑定到paper-item属性value ,如下所示。 But it's NOT work:但它不起作用:

<paper-item value="{{item.id}}">{{index}} - {{item.id}} - {{item.name}}</paper-item>

The results:结果:

<paper-item>0 - 100 - Item 1</paper-item>
<paper-item>1 - 103 - Item 2</paper-item>

Questions: How to make this case works?问题:如何使这个案例起作用?

也许您应该使用属性绑定语法

<paper-item value$="{{item.id}}">{{index}} - {{item.id}} - {{item.name}}</paper-item>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM