2016-07-25 19 views
1

Ionic2Angular2を使用して、選択ボックスからオプション「その他」を選択すると職業を入力するオプションをユーザに与えたいと考えています。選択のionic2選択ボックスから他のオプションを選択した場合の入力フィールド

例:ここでは

enter image description here

コードは次のとおりです。

あなたは userTypeプロパティを使用し、その値が等しいときに入力を示すことができ

\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

の値に他のオプション:

<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

関連する問題