input[type=radio]
Cross bind a value to a radio input.
Binding to radios
To bind to a radio input, if you have a set of boolean values you can bind to the input’s checked
property as you do with input[type=checkbox].
<input type="radio" checked:bind="one" /> One
<input type="radio" checked:bind="two" /> Two
var template = stache.from("demo");
var map = new DefineMap({
one: true,
two: false
});
document.body.appendChild(template(map));
Binding to a selected value
More often than binding to boolean values of each radio's checked
value, you will want to know what the value
is of the radio group. Since each radio has its own value
, the radio's selected value is the value of the radio item that is selected.
Using the equal converter you can bind a value within your scope to the radio group’s selected value: