【问题标题】:How to submit ionic Radio button value on button click?如何在按钮单击时提交离子单选按钮值?
【发布时间】:2021-12-17 14:32:03
【问题描述】:

点击提交按钮时需要传递选中单选按钮的值

<!--Starts Location Select Popover -->
<ion-list>
  <ion-list-header>
    <h5> Select Location</h5>
  </ion-list-header>
  <ion-item *ngFor="let store of storeLocations">
    <ion-label>{{store?.storeName}}</ion-label>
    <input type="radio" slot="end" value="{{store}}" />
  </ion-item>
  <ion-button expand="block" (click)="dismissLocationSelectPopover(store)">Submit Location
  </ion-button>
</ion-list>
<!--Ends Location Select Popover -->

【问题讨论】:

  • 在输入时使用[(ngModel)]="yourVariable"。并将yourVariable 传递给您的函数。

标签: ionic-framework button radio-button radio


【解决方案1】:

[(ngModel)] 不受支持。最好改用(click)

HTML

<input type="radio" slot="end" value="{{storeLoc.storeName}}" id="{{storeLoc.storeName}}"(click)="storeSelected(storeLoc)" />

TS

  storeSelected(storeLoc) {
    this.storeSelected = storeLoc;
  }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-12
    • 2020-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-27
    相关资源
    最近更新 更多