Hi,
I’m trying to fork the interaction on first page load: if user is authenticated then he goes to a sidenav menu page, else he goes to a login page, here’s the code:
import { Component, ViewChild } from '@angular/core';
import { Nav } from 'ionic-angular';
import { UserLoginService, LoggedInCallback } from '../services/cognito.service';
import { LoginPage } from '../pages/login/login';
import { MenuPage } from '../pages/menu/menu';
@Component({
template: '<ion-nav [root]="rootPage" scrollbar-y-auto></ion-nav>'
})
export class MyApp {
@ViewChild(Nav) private nav: Nav;
rootPage: any;
constructor(public userService: UserLoginService) {
this.goToRootPage();
}
private goToRootPage() {
this.userService.isAuthenticated({
isLoggedInCallback: function (message, loggedIn) {
if (loggedIn) {
this.nav.setRoot(MenuPage);
}
else {
this.nav.setRoot(LoginPage);
}
}
});
}
}
this.nav
is undefined
, how can I navigate to LoginPage or MenuPage?