如何在按钮单击时提交离子单选按钮值?
How to submit ionic Radio button value on button click?
需要在单击提交按钮时传递所选单选按钮的值
<!--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)]
。最好改用 (click)
。
HTML
<input type="radio" slot="end" value="{{storeLoc.storeName}}" id="{{storeLoc.storeName}}"(click)="storeSelected(storeLoc)" />
TS
storeSelected(storeLoc) {
this.storeSelected = storeLoc;
}
需要在单击提交按钮时传递所选单选按钮的值
<!--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)]
。最好改用 (click)
。
HTML
<input type="radio" slot="end" value="{{storeLoc.storeName}}" id="{{storeLoc.storeName}}"(click)="storeSelected(storeLoc)" />
TS
storeSelected(storeLoc) {
this.storeSelected = storeLoc;
}