[SOLVED] How-to ion-radio read and set null value in ionic2


#1

Hi,

Is it possible in ionic2 to work with ion-radio and null value?

I want to achieve something like

<ion-list radio-group [(ngModel)]="item">
<ion-item>
  <ion-label>Yes</ion-label>
  <ion-radio value="true"></ion-radio>
</ion-item>

<ion-item>
  <ion-label>No</ion-label>
  <ion-radio value="false"></ion-radio>
</ion-item>

<ion-item>
  <ion-label>Doesn't matter</ion-label>
  <ion-radio value="null"></ion-radio>
</ion-item>
</ion-list>

But of course this doesn’t work, since null in the ion-radio is converted to a “null” (string) value.

Any idea how to implement a ion-radio component with a null value?


#2

So that seems to work. Just to be sure I added a click to effectively set “null” and not undefined or whatever (Ionic2 RC.1).

<ion-radio value="{{null}}" (click)="select()"></ion-radio>