Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Conditional Root Page

$
0
0

@miropolis wrote:

Hey
I want to bring up the topic of a conditional root Page again. I am aware that there have been some topics on this in the past but nothing very recent and I would like some input.

So this is my current solution. isLoggedIn is a boolean variable. This is in my app.component.ts:

export class MyApp {

  rootPage: any
  

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, storage: Storage) {
    
    storage.get("isLoggedIn").then((status) => {
      console.log("component logged in?", status)
      if(status) {
        this.goToTabsPage()
      } else{
        this.goToLoginPage()
      }
    });

    platform.ready().then(() => {
      statusBar.styleDefault();
      splashScreen.hide();
     });
  }
  
  goToTabsPage ( ) {
    this.rootPage = "TabsPage"
  }
  goToLoginPage() {
    this.rootPage = "LoginPage"
  }
}

This seems to work fine so far, but I am sure there are better/faster ways to do it.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>