2016-07-25 133 views
1

使用Ionic2Angular2,我想给用户一个选项,当他们从选择框中选择选项'其他'时进入专业。选择的ionic2当从选择框中选择其他选项时,显示输入字段

例子:

enter image description here

下面是代码:

\t <ion-item> 
 
\t \t <ion-label>Select Profession</ion-label> 
 
\t \t <ion-select [(ngModel)]="userType"> 
 
\t \t \t <ion-option *ngFor="let ut of userTypeList" [value]="ut.value" [innerHTML]="ut.label"></ion-option> 
 
\t \t </ion-select> 
 
\t </ion-item>

回答

2

您可以使用userType财产和显示输入时,其值等于到的其他值选项:

<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> 
+0

谢谢!有效。 –

+0

很高兴有帮助:) – sebaferreras

相关问题