Ionic framework 离子选择中的下拉列表
我正在用ionic开发一个应用程序,在该应用程序中,我应该显示输入框,如pnr no、train no,当从下拉列表中选择train时,以及当我从下拉列表中选择bus时,它应该输入与bus相关的框,如seat no等。检查此代码,这将起作用 在.html页面中:Ionic framework 离子选择中的下拉列表,ionic-framework,Ionic Framework,我正在用ionic开发一个应用程序,在该应用程序中,我应该显示输入框,如pnr no、train no,当从下拉列表中选择train时,以及当我从下拉列表中选择bus时,它应该输入与bus相关的框,如seat no等。检查此代码,这将起作用 在.html页面中: 将此答案标记为已接受,如果有效,则向上投票: 谢谢你和我们分享。你有问题吗? <ion-label floating>Travel By</ion-label> <ion-select (ionCancel
将此答案标记为已接受,如果有效,则向上投票: 谢谢你和我们分享。你有问题吗?
<ion-label floating>Travel By</ion-label>
<ion-select (ionCancel)="cancel()">
<ion-option value="Bus" (ionSelect)="selectTravel('Bus');">Bus</ion-option>
<ion-option value="Train" (ionSelect)="selectTravel('Train');">Train</ion-option>
</ion-select>
<ion-label floating *ngIf="isTrainSelected">Train No</ion-label>
<ion-input *ngIf="isTrainSelected"></ion-input>
<ion-label floating *ngIf="isBusSelected">Seat No</ion-label>
<ion-input *ngIf="isBusSelected"></ion-input>
public isTrainSelected: boolean;
public isBusSelected: boolean;
selectTravel(Mode)
{
if(Mode == 'Bus')
{
this.isTrainSelected = false;
this.isBusSelected = true;
}
else if(Mode == 'Train')
{
this.isBusSelected = false;
this.isTrainSelected = true;
}
}
cancel()
{
this.isBusSelected = false;
this.isTrainSelected = false;
}
ionViewDidLoad()
{
//make it invisible on page load
this.isBusSelected = false;
this.isTrainSelected = false;
}