离子无线电改变时的值错误

时间:2018-11-26 09:24:32

标签: ionic-framework ionic2 ionic3

尝试更改单选按钮值并将其发布到我的soap writeData中时,出现一个奇怪的错误。例如,我尝试将性别从M更改为F,我进行console.log记录,更改结果的值如下:rb-1-0

这是我的代码:

<div radio-group formControlName="gender" style="margin-top:-3%;margin-left:23%" [(ngModel)]="customer.SESSO">
    <ion-radio color="dark" [value]="F" [checked]="customer.SESSO == 'f'"></ion-radio>
    <span>
      <strong style="position: absolute;margin-top: -1%; margin-left: 2%;font-size:16px">F</strong>
    </span>
  </div>
  <div radio-group formControlName="gender" style="margin-left: 47%;margin-top: -10%" [(ngModel)]="customer.SESSO"
  class="radio-privacy in-middle">
    <ion-radio color="dark" [value]="M" [checked]="customer.SESSO == 'm'"></ion-radio>
    <span>
      <strong style="position: absolute;margin-top: -1%;margin-left: 4%;font-size:16px">M</strong>
    </span>
  </div>

1 个答案:

答案 0 :(得分:1)

此代码对于普通的单选按钮组应该可以正常工作,请根据需要自定义CSS。

<ion-list radio-group style="margin-top:-3%;margin-left:23%" [(ngModel)]="customer.SESSO">

  <ion-item>
    <ion-label>Female</ion-label>
    <ion-radio color="dark" value="F" [checked]="customer.SESSO == 'F'"></ion-radio>
  </ion-item>

  <ion-item>
    <ion-label>Male</ion-label>
    <ion-radio color="dark" value="M" [checked]="customer.SESSO == 'M'"></ion-radio>
  </ion-item>

</ion-list>