2016-08-25 187 views
0

當我選擇選項時,我想顯示輸入文本標籤。當從選擇框中選擇特定選項時顯示輸入字段 - Ionic2

HTML代碼

<ion-item > 
    <ion-label floating>TIN/GRN NO</ion-label> 
    <ion-select [(ngModel)]="num"> 
    <ion-option *ngFor="let nom of list" value="{{nom.value}}" checked=" {{nom.checked}}" [innerHTML]="nom.label">{{nom.text}}</ion-option> 
    </ion-select> 
    </ion-item> 
    <ion-item *ngIf="num == 'true'"> 
    <ion-label>Detail</ion-label> 
    <ion-input type="text"></ion-input> 
    </ion-item> 

TS文件

num = 'true'; 
list: Array<{ value: number, text: string, checked: boolean }> = []; 

constructor: 
     this.list.push({ value: 1, text: 'TIN NO', checked: false }); 
     this.list.push({ value: 2, text: 'GRN NO' , checked: false }); 

回答

0

既然你做<ion-select [(ngModel)]="num">num屬性將有值或(不正確或假),所以在你看來,你需要與這些進行比較值:

<ion-item *ngIf="num == 1"> 
    <ion-label>Detail</ion-label> 
    <ion-input type="text"></ion-input> 
    </ion-item> 
+0

其實我有兩個選擇,當我點擊我要顯示輸入text.In這種情況下,如果我給NUM == 1,如果我選擇第一個選項,然後只給它輸入選項中的任何一個第二個選項它沒有給出輸入文本。 – balaji

+0

對不起,我沒有理解你的評論中的問題。您可以顯示更多選項的輸入,例如'* ngIf =「num == 1 || num == 2」' – sebaferreras

+0

謝謝。 – balaji

相關問題