当从 select 框 selected 其他选项时,ionic2 显示输入字段
ionic2 show input field when other option is selected from select box
使用 Ionic2
和 Angular2
,我想在用户从 select 框中 select 选择 'Other' 时,为用户提供进入职业的选项。
Select 示例:
代码如下:
<ion-item>
<ion-label>Select Profession</ion-label>
<ion-select [(ngModel)]="userType">
<ion-option *ngFor="let ut of userTypeList" [value]="ut.value" [innerHTML]="ut.label"></ion-option>
</ion-select>
</ion-item>
您可以使用 userType
属性 并在其值等于 other 选项的值时显示输入:
<ion-item>
<ion-label>Select Profession</ion-label>
<ion-select [(ngModel)]="userType">
<ion-option *ngFor="let ut of userTypeList" [value]="ut.value" [innerHTML]="ut.label"></ion-option>
</ion-select>
</ion-item>
<ion-item *ngIf="userType == 'otherOptionValue'">
<ion-label>Detail</ion-label>
<ion-input type="text"></ion-input>
</ion-item>
使用 Ionic2
和 Angular2
,我想在用户从 select 框中 select 选择 'Other' 时,为用户提供进入职业的选项。
Select 示例:
代码如下:
<ion-item>
<ion-label>Select Profession</ion-label>
<ion-select [(ngModel)]="userType">
<ion-option *ngFor="let ut of userTypeList" [value]="ut.value" [innerHTML]="ut.label"></ion-option>
</ion-select>
</ion-item>
您可以使用 userType
属性 并在其值等于 other 选项的值时显示输入:
<ion-item>
<ion-label>Select Profession</ion-label>
<ion-select [(ngModel)]="userType">
<ion-option *ngFor="let ut of userTypeList" [value]="ut.value" [innerHTML]="ut.label"></ion-option>
</ion-select>
</ion-item>
<ion-item *ngIf="userType == 'otherOptionValue'">
<ion-label>Detail</ion-label>
<ion-input type="text"></ion-input>
</ion-item>