我有以下代碼以下在https://github.com/dart-lang/polymer-core-and-paper-examples/blob/master/web/paper_dropdown.html和EDITED檢索在紙面元件下拉列表中選擇的項目
例子https://github.com/dart-lang/polymer-core-and-paper-examples/blob/master/web/paper_dropdown.dart
的.html
<paper-dropdown-menu
label='Click to select..'
on-core-select='{{onCoreSelectCountryHandler}}'>
<paper-dropdown class='dropdown'>
<core-menu id='country' class='menu'>
<template repeat='{{country in countries}}'>
<paper-item>{{country.name}}</paper-item>
</template>
</core-menu>
</paper-dropdown>
</paper-dropdown-menu>
.dart
final List<Country> countries = [
const Country('Afghanistan', 'AF'),
const Country('Åland Islands', 'AX')];
class Country {
final String name;
final String code;
const Country(this.name, this.code);
}
void onCoreSelectCountryHandler(dom.CustomEvent e, var detail) {
var detail = new JsObject.fromBrowserObject(e)['detail'];
if (detail['isSelected']) {
// DOES NOT WORK - HOW DO I GET THE SELECTION ATTEMPTED BELOW
// The detail should be related to the Country class but
// I can't seem to relate it so I could get the selection.
var kuntry = (detail['item'] as PaperItem).text;
}
如何使用dart代碼檢索下拉(通常顯示)中的選定元素?
沒問題,只是爲了保持Dart區域得到良好的維護:) –