【发布时间】:2014-09-24 12:51:19
【问题描述】:
我的 Polymer 元素的 Dart 代码如下所示:
@CustomTag('my-element')
class MyElement extends PolymerElement {
final List<String> colors = toObservable(['red', 'green', 'blue']);
MyElement.created() : super.created();
}
HTML 看起来像这样:
<polymer-element name="my-element">
<template>
<style>
.core-selected {
font-weight: bold;
}
</style>
<core-selector id="selector" selected="1">
<template repeat="{{color in colors}}">
<div value="{{color}}">{{color}}</div>
</template>
</core-selector>
<hr>
<!-- Prints the selected index, but does not update -->
<div>{{$['selector'].selected]}}</div>
</template>
<script type="application/dart" src="my_element.dart"></script>
</polymer-element>
使用<div>{{$['selector'].selected]}}</div> 可以正确显示所选color 的索引,但选择不同的颜色不会刷新selected 的值。我正确使用它吗?或者这是一个错误?
【问题讨论】:
-
我希望这能奏效。
selected是一个已发布的属性,因此应该是可观察的。也许是 Dart 包装器的问题。 -
君特,我相信你是对的。我提交了一个错误:github.com/dart-lang/core-elements/issues/115.
-
你打错了:{{$['selector'].selected]}} 应该是 {{$['selector'].selected}}
标签: dart dart-polymer