【发布时间】:2020-03-12 03:55:49
【问题描述】:
我有这样的东西 .html
<ion-item>
<ion-label>Choose Industry Type</ion-label>
<ion-select (ionChange)="getOuterName()" [(ngModel)]="getSelectedValue">
<ion-option *ngFor="let some of someItems" value="{{some.id}}">
{{some.name}} </ion-option>
</ion-select>
</ion-item>
<p>{{getSelectedValue}}</p>
.ts
someItems = [{'id': 1, 'name':'Agriculture','othervalue':'123'},
{'id': 2, 'name':'Chemicals','othervalue':'1234'},
{'id': 3, 'name':'Pesticides','othervalue':'12345'}];
getOuterName(){
console.log(this.getSelectedValue);
let term = this.someItems.filter(item => item.othervalue ===this.getSelectedValue );
}
我可以在 'getSelectedValue' 中显示 'othervalue' 而不更改 value="{{some.id}}"离子选项?
【问题讨论】:
-
那么现在显示的是什么值?因为你使用过 ngModel,它应该显示值。