2014-10-01 54 views
1

可以将在core-list-dart元素中选择的项目绑定到变量?core-list-dart绑定选择属性

喜欢的东西:

<core-list-dart data={{data}} height="80" selected={{selected}}> 

如果数据是我List<Item>和选择是Item

+0

分配给'selected'的值是多少?这不是选定的项目吗? – 2014-10-01 13:58:25

+0

所选值保留为空。 – Fedy2 2014-10-01 14:02:02

+0

相关问题https://github.com/dart-lang/core-elements/issues/121 – 2014-10-02 06:53:06

回答

0

core-activate事件通过所选项目。

void activateHandler(dom.CustomEvent e) { 
    print(e.detail.data); 
} 
<core-list-dart data={{data}} height="80" on-core-activate="{{activateHandler}}"> 

core-list不提供selected属性,但在模板中的项目一样。

<core-list-dart data="{{data}}" on-core-activate="{{activateHandler}}"> 
    <template> 
     <div>{{name}} - selected: {{selected}}</div> 
    </template> 
</core-list-dart> 

我用你Foo类为例,从您的其他问题core-list-dart template how to bind to the model itself

+0

我更新了我的答案。 – 2014-10-01 14:30:01

+0

有一个选定的属性,但没有文档:http://www.dartdocs.org/documentation/core_elements/0.3.0+1/index.html#core_elements/core_elements-core_[email protected]_selected – Fedy2 2014-10-01 14:59:04

+0

我已经看到它了在代码中,但它似乎并没有得到更新,并且Polymer.js核心列表根本没有它。 – 2014-10-01 15:12:40

0

core-list-dartselected属性不记录https://github.com/dart-lang/core-elements/issues/121

正如我从代码中可以理解的那样,对于更改观察属性,选择应该随之更新,但不起作用。

唯一的解决方案是通过GünterZöchbauer提出的core-activate事件听取选择更改。

事件details.data属性包含所选项目。

+0

我认为这个可观察的'selected'字段存在错误,因为Polymer.js元素没有它。但我认为对你创建的问题的回应将告诉我... – 2014-10-02 07:30:45

+0

我不太确定是否有错误,因为该字段是“观察”,并在这里使用:https://github.com/dart-lang/core -elements /斑点/主/ LIB/core_list_dart.dart#L361 – Fedy2 2014-10-02 07:34:07