How to load a Page based on certain result in Ionic With Angular


#1

I want to show RegisterPage, based on the result of, if condition inside the constructor. I’m new to Ionic and Angular. Can anyone suggest me to do this requirement

app.component.ts

export class MyApp {
@ViewChild(Nav) navCtrl: Nav;
    rootPage:any = RegisterPage;

    constructor(platform: Platform) {
   platform.ready().then(() => {
      statusBar.styleDefault();
      splashScreen.hide();
      if(localStorage["User"]||localStorage["Tenant"]===null){      
      this.navCtrl.push(RegisterPage);             //call reg form
      }
        else{
        //call login form        
        }
    });
  }
}

app.html

<ion-nav #mainContent [root]="rootPage"></ion-nav>


#2
platform.ready().then(() => {
          if(localStorage["User"]||localStorage["Tenant"]===null)
           {
            this.rootPage = RegisterPage; 
          }
          else{
            this.rootPage = LoginPage;
         }
 });

Finally this code solves my problem…