0

我的选项值是从服务器下载的。服务器返回结果后如何更新选项值?

 <select name="book" template iterate="book in books" bind-value="selected">
 <option selected="{{selected == book}}">{{book}}</option>
 </select>

在 .dart

 List<String> books= <String>[''];
 @observable
 String selected = 'Doraemon';
 void main() {
      var request = HttpRequest.getString(url).then((jstr){
      // Parse json
      Map data = json.parse(jstr);
      print(data['option']['books']);
      // Refresh the list, but how to refresh option value?
      books.addAll(data['option']['books']);
 }
4

1 回答 1

1

您应该将书籍价值包装在对“toObservable”的调用中。https://www.dartlang.org/web-ui/observables/#observing-collections

List<String> books= toObservable(<String>['']);
于 2013-08-12T14:05:49.343 回答