New solution, now a little more elegant. I only install the root programmatically after I get to the repository and check if it should display Home or Login.
@Component({ template: `<ion-nav #nav></ion-nav>` ) export class MyApp { @ViewChild('nav') nav: Nav; constructor(platform: Platform, storage: Storage) { this.storage.get('isLogged').then(logged => { if (logged) { this.nav.setRoot(HomePage); } else { this.nav.setRoot(LoginPage); } }); }
Before editing
Not an ellegant solution, and I will see if there is a better way, but in my case I delayed showing the root with * ngIf.
My AppComponent looks something like this:
@Component({ template: `<ion-nav *ngIf="showRoot" [root]="rootPage"></ion-nav>` }) export class MyApp { rootPage:any = LoginPage; showRoot = false; constructor(platform: Platform, storage: Storage) { this.storage.get('isLogged').then(logged => { if (logged) { this.rootPage = HomePage; } this.showRoot = true; }); } }
source share