Javascript 获取ionic4中离子选择选项的名称
我无法从ion select获取名称。我可以使用[ngmodel]从离子选择选项中获取值。但是,我可以找到如何从选定的离子选择选项中获取名称Javascript 获取ionic4中离子选择选项的名称,javascript,ionic-framework,ionic4,Javascript,Ionic Framework,Ionic4,我无法从ion select获取名称。我可以使用[ngmodel]从离子选择选项中获取值。但是,我可以找到如何从选定的离子选择选项中获取名称 <ion-item> <ion-select placeholder="Select User" [(ngModel)]="selectedUser" (ionChange)="selectedUser1(selectedUser)" style="width:100%;max-width:100%;">
<ion-item>
<ion-select placeholder="Select User" [(ngModel)]="selectedUser" (ionChange)="selectedUser1(selectedUser)" style="width:100%;max-width:100%;">
<ion-select-option *ngFor="let item of user" value="{{item.pos_id}}">{{item.pos_name}}</ion-select-option>
</ion-select>
</ion-item>
我需要在typescript变量中获取{{item.pos_name}}-name。请帮助我获取所选离子选择选项的名称:您可以在用户数组中循环查找名称和其他信息,如
selectedUser1(selectedUser){
this.user.map(val, index){
if(selectedUser == val.pos_id){
console.log(val); // this will print your complete object of user.
}
}
}
2选项:使用id将名称作为值传递
{{item.pos_name}
您将在所选的用户ngModel中获得id和名称。你可以根据需要把它分开