【发布时间】:2015-10-26 11:17:00
【问题描述】:
我对与聚合物中的数组进行数据绑定感到非常困惑,我认为这是一个非常简单的用例。
我有一个元素,具有一个数组作为属性,我想为数组中的每个项目显示一个子元素列表。
<dom-module id="parent-element">
<template>
<h1>This is the parent!</h1>
<template is="dom-repeat" items="{{arrayproperty}}" as="item">
<child-element
propertyone="{{item.propertyone}}"
propertytwo="{{item.propertytwo}}">
</child-element>
</template>
</template>
</dom-module>
这段代码很好用。创建适当数量的子元素,并将数组中的属性传递给子元素。但是,当子元素属性发生更改时,这些更改不会传递回父元素数组属性。如何使用双向绑定配置此设置,以便父元素从子元素获取更新?
【问题讨论】:
标签: javascript arrays data-binding polymer