获取 ionic 4 中 ion-radio-group 标签的选定值

or1*_*456 3 ionic-framework angular ionic4

我在下面有一个代码:

<ion-item>
 <ion-radio-group [value]="profileItem.Sex" [(ngModel)]="profileItem.Sex">
  <ion-label class="input-label">{{ 'GENDER' | translate }}</ion-label>
  <div style="display: flex;">
    <span *ngFor="let genderType of genderTypeList">
      <span>{{genderType.title}}</span>
      <ion-radio [disabled]="profileItem.id" [value]="genderType.value"></ion-radio>
    </span>
  </div>
 </ion-radio-group>
</ion-item>
Run Code Online (Sandbox Code Playgroud)

但无法在 profileItem.Sex 中获取选定值。
profileItem.Sex 没有改变。
如何在 ion-radio-group 标签中获得选定的值?

小智 5

您还可以将 ion-select 与 ionChange 事件一起使用:

 <ion-select (ionChange)="checkValue($event)"  interface="popover" 
      placeholder="Select One" >
        <ion-select-option *ngFor="let item of userData" [value]="item"> 
       {{item.optionA}}</ion-select-option>
 </ion-select>
Run Code Online (Sandbox Code Playgroud)

在你的打字稿中:

checkValue(event){ console.log(event.detail.value)}
Run Code Online (Sandbox Code Playgroud)