小编Var*_*hah的帖子

如何动态地在离子2中的下拉列表中添加值

我想在我的表格中下拉.我知道如何静态地在下拉列表中添加选项,但是,我希望它是动态的.

我的代码

<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文件中该怎么做.如何为项目赋值?

javascript ionic2

4
推荐指数
1
解决办法
9711
查看次数

如何从离子2中的下拉列表中获取选定值

我在页面中设置了下拉菜单,但是如何获取选择的值.我用的代码

<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)

typescript ionic2 ionic3 angular

1
推荐指数
1
解决办法
7728
查看次数

标签 统计

ionic2 ×2

angular ×1

ionic3 ×1

javascript ×1

typescript ×1