dart - How do I set a default selected option in a Web UI <select> tag? -
i have have <select> tag few options. how set default selected option?
here dart code:
import 'dart:html'; import 'package:web_ui/web_ui.dart'; list<string> fruits = const <string>['apples', 'bananas', 'pears']; @observable string selected = 'pears'; void main() { } here html code:
<p>hello world dart! chose {{ selected }}</p> <select name="fruit" template iterate="fruit in fruits" bind-value="selected"> <option selected="{{selected == fruit}}">{{fruit}}</option> </select> note, there open request make bit easier. in meantime, above code should work you.
Comments
Post a Comment