lucassp lucassp -5 years ago 137
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>


Answer Source

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




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download