lucassp lucassp - 4 months ago 36x
Javascript Question

Model won't update in Angular 2 radio list

I'm trying to build a Angular 2 component which displays a list of options with radios. It works fine but it the

field of the component, which is bound inside
, won't update when selecting one of the options. Am I doing something wrong or isn't this the way to create a list of radio selection options?

Answer: {{ answer }}
<div class="radio" *ng-for="#option of itemData">
<input type="radio" [value]="" [(ng-model)]="answer"
(change)="responseChanged()" name="radio-list">
<span>{{ }}</span>



Well i guess two way binding is now working with radio, so currently you cannot use [(ng-model)].

The alternative is to use the change event and checked attribute. See my plunker