How can I use a ngModel on an ion-radio element?
Syntax has been changed rewritten now, ngModel
should be place with ion-list
& radio-group
only once. No need to have them there on each ion-radio
element.
<ion-list radio-group [(ngModel)]="unit">
<ion-list-header>
Unit
</ion-list-header>
<ion-item>
<ion-label>Metric (kg)</ion-label>
<ion-radio value="1"></ion-radio>
</ion-item>
<ion-item>
<ion-label>Imperial (lbs)</ion-label>
<ion-radio value="2" ></ion-radio>
</ion-item>
</ion-list>
For more information you could visit ionic2 framework forum link
As of Ionic 4+, the correct sintax is:
<ion-list>
<ion-radio-group [(ngModel)]="unit">
<ion-list-header>
Unit
</ion-list-header>
<ion-item>
<ion-label>Metric (kg)</ion-label>
<ion-radio value="1"></ion-radio>
</ion-item>
<ion-item>
<ion-label>Imperial (lbs)</ion-label>
<ion-radio value="2"></ion-radio>
</ion-item>
</ion-radio-group>
</ion-list>
It's working with Ionic 5.
<ion-radio-group value="answer">
<ion-item *ngFor="let item of question?.answers">
<ion-label> {{item.answer}} {{answer}}</ion-label>
<ion-radio slot="start" color="tertiary" value="{{item.id}}
(ionBlur)="saveAnswer(item.id)">
</ion-radio>
</ion-item>
</ion-radio-group>