Ionic 3 first rootPage on condition

时间:2017-08-04 12:47:00

标签: ionic-framework ionic3

I want my ionic 3 app to check a localy stored variable right after the app is loaded (after splash), and then set the rootPage accordingly. I need to know where should I put the code for this functionnality.

1 个答案:

答案 0 :(得分:0)

Check out the conference Ionic template.

You can create the app directly from the ionic CLI:

ionic start conference-demo conference

The relevant part is in the src/app/app.component.ts file:

this.storage.get('myStoredVariable')
    .then((myStoredVariable) => {
        if (myStoredVariable) {
            this.rootPage = customPage;
        } else {
            this.rootPage = defaultPage;
        }
    });
}