我想在我的表格中下拉.我知道如何静态地在下拉列表中添加选项,但是,我希望它是动态的.
我的代码
<ion-item>
<ion-label>Select Type</ion-label>
<ion-select [(ngModel)]="selectedvalue" #item>
<ion-option *ngFor="let item of items" [value]="item">{{item}}</ion-option>
</ion-select>
</ion-item>
Run Code Online (Sandbox Code Playgroud)
我为此编写了html代码.但我不知道在我的.ts文件中该怎么做.如何为项目赋值?
我在页面中设置了下拉菜单,但是如何获取选择的值.我用的代码
<ion-item>
<ion-label>MemberType</ion-label>
<ion-select [(ngModel)]="selectedvalue" #item >
<ion-option *ngFor="let item of items" value="{{item.value}}" checked="{{item.checked}}">{{item.text}}</ion-option>
</ion-select>
</ion-item>
items: Array<{ value: number, text: string, checked: boolean }> = [];
this.items.push({ value: 1, text: 'Super Distributor', checked: false });
this.items.push({ value: 2, text: 'Distributor', checked: false });
this.items.push({ value: 3, text: 'Retailer', checked: false });
this.items.push({ value: 4, text: 'End User', checked: false });
Run Code Online (Sandbox Code Playgroud)