Binding to radio buttons
In this recipe, we will show you how to bind an input value from a radio button to a variable; so in effect, we now perform data binding from the UI to the code and have two-way data binding. You can find the code in the project pol_radio
.
How to do it...
- The script starts with
web\index.html
, where a component with the namepol-radio
is imported through the following line:<link rel="import"href="pol_radio.html">
From this, we know that the component is defined in
pol_radio.html
, and the code behind it is in a file namedpol_radio.dart
. For a discussion of the other tags, refer to the first recipe. - The code for
pol-radio
is defined inpol_radio.dart
:import'dart:html'; import'package:polymer/polymer.dart'; @CustomTag('pol-radio') classPolradio extends PolymerElement { @observable String favoriteJob = ''; Polradio.created() : super.created(); voidgetFavoriteJob(Event e, var detail, Node target...