我想显示 RegisterPage,基于构造函数中 if 条件的结果。我是Ionic和Angular的新手。谁能建议我做这个要求。
app.component.ts
export class MyApp {
@ViewChild(Nav) navCtrl: Nav;
rootPage:any = RegisterPage;
constructor(platform: Platform) {
platform.ready().then(() => {
if(localStorage["User"]||localStorage["Tenant"]===null){
this.navCtrl.push(RegisterPage); //call reg form
}
else{
//call login form
}
});
}
}
应用.html
<ion-nav #mainContent [root]="rootPage"></ion-nav>
platform.ready().then(() => {
if(localStorage["User"]||localStorage["Tenant"]===null)
{
this.rootPage = RegisterPage;
}
else{
this.rootPage = LoginPage;
}
});
试试这个