我有下一个代码:
@CustomTag('my-element')
class MyElement extends PolymerElement {
MyElement.created() : super.created();
@published ObservableList persons = toObservable([]);
handleAdd() {
persons.add({'name': 'jhon', 'lastName': 'Doe'});
}
handleRemove() {
persons.remove({'name': 'jhon', 'lastName': 'Doe'});
}
}
这是HTML:
<polymer name="my-element">
<template>
<template repeate="{{p in persons}}">
{{p['name']}} {{p['lastName']}}
</template>
<button on-click="{{handleAdd}}">add person</button>
<button on-click="{{handleRemove}}">remove person</button>
<template>
</polymer>
调试时,它会从对象的内部列表中添加和删除。但是,它从不显示 HTML 中添加的元素。