问题
I have this Ionic
version 4 code that is simply trying to take a the selected value and pass it to a function in it's component:
<ion-item>
<ion-label>Convert Currency</ion-label>
<ion-select [(ngModel)]="currency">
<ion-select-option *ngFor="let c of currencyData" [value] = "c" >{{c.text}}</ion-select-option>
</ion-select>
I tried onChange
but that is apparently not in version 4.
回答1:
You are looking for ionChange
<ion-select [(ngModel)]="currency" (ionChange)="yourFunction($event)">
回答2:
you can use ionChange to pass the selected value as follow :
<ion-select (ionChange)="checkValue($event)" interface="popover"
placeholder="Select One" >
<ion-select-option *ngFor="let c of currencyData" [value]="c">
{{c.text}}</ion-select-option>
</ion-select>
In your typeScript:
checkValue(event){ console.log(event.detail.value)}
来源:https://stackoverflow.com/questions/53551889/pass-ion-select-option-to-function-ionic-4