更改铁列表中现有项的绑定属性的值
Change the value of a bound property on an existing item in iron-list
我的iron-list
中绑定了一个项目,当我更改对象的绑定属性时,我希望看到屏幕上反映的更改,但我没有。做错了什么?
https://jsfiddle.net/ckqL3a3o/3/
<link rel="import" href="https://cdn.rawgit.com/Download/polymer-cdn/1.2.3.2/lib/polymer/polymer.html">
<link rel="import" href="https://cdn.rawgit.com/Download/polymer-cdn/1.2.3.2/lib/iron-list/iron-list.html">
<script src="https://google.github.io/traceur-compiler/bin/traceur.js"></script>
<script src="https://google.github.io/traceur-compiler/bin/BrowserSystem.js"></script>
<script src="https://google.github.io/traceur-compiler/src/bootstrap.js"></script>
<template is="dom-bind" id="app">
<div style="width: 500px; height: 300px; background: #eee; overflow: auto; float:left">
<iron-list items="{{data}}" as="item" style="width: 500px; height: 300px;">
<template>
<p><span>{{item.name}}</span> <span>{{item.value}}</span></p>
</template>
</iron-list>
</div>
</template>
<script type="module">
'use strict';
var app = document.querySelector('#app');
app.data = [{ name: 'item', value: 3 }];
setTimeout(() => app.data[0].value = 4, 2000);
</script>
您需要使用 Polymers API 修改 Polymer 的模型数据才能获得通知
setTimeout(() => this.set('app.data.0.value', 4), 2000);
参见
- https://www.polymer-project.org/1.0/docs/devguide/data-binding.html#set-path
- https://www.polymer-project.org/1.0/docs/devguide/data-binding.html#array-binding
- https://www.polymer-project.org/1.0/docs/devguide/properties.html#notifysplices
相关文章:
- Ember.js/HHandlebars:使用{{view}}助手渲染的视图不绑定属性
- 聚合物 - 在重复模板中获取数据绑定属性值
- 如果指令包含在另一个指令中,我如何在隔离范围内添加双向数据绑定属性
- AngularJS1.2 Directive双向绑定属性未反映到View
- 为什么AngularJS在页面加载时没有自动绑定属性?包括一个非常简单的例子
- 如何在AngularJS指令中绑定属性
- 更改铁列表中现有项的绑定属性的值
- 如何使用 angularjs 中的表达式绑定属性名称
- Angular 指令内部 HTML 重新编译,动态创建绑定属性
- 标识事件中的绑定属性
- AngularJS 指令未正确绑定属性
- 在显示绑定属性之前在 JavaScript 中格式化绑定属性
- 从数据绑定属性迭代键值对
- 剑道绑定属性与字符串和变量
- 如何在一个元素上具有多个数据绑定属性
- 无法识别余烬组件 - 绑定属性渗入控制器
- 挖空添加我自己的数据绑定属性,如 With
- Emberjs如何绑定属性和id
- Ember绑定属性没有更新,尽管控制器属性更新得很好
- 如何在Knockout中选择性地绑定属性