In my changeView()
method, I am performing checks on certain authentications and permissions.
Below is the actual method:
changeView () : void {
let navCtrl: NavController = this.app.getActiveNavs()[0];
let hasFetchedDashboardPermission: boolean = this.permissionService.hasFetchedMenuPermission(PermissionId.PAGE_HOME);
// let testNav;
console.log(this.globalService.isAuthenticated(), !hasFetchedDashboardPermission, navCtrl.getActive() !== undefined)
if(navCtrl.getActive() !== undefined){
console.log('active navCtrl', navCtrl.getActive().id)
}
if (this.globalService.isAuthenticated() && hasFetchedDashboardPermission
&& navCtrl.getActive() !== undefined && navCtrl.getActive().id !== 'home' && navCtrl.getActive().id !== 'collegekaart') {
console.log('setHome');
navCtrl.setRoot('home');
} else if (this.globalService.isAuthenticated() && !hasFetchedDashboardPermission
&& navCtrl.getActive() !== undefined && navCtrl.getActive().id !== 'login') {
this.globalService.deleteApiSecurityParams();
console.log('check1', navCtrl.isTransitioning());
let test = this.app.getActiveNavs();
test[0].setRoot('login');
this.testNav = this.app.getRootNavById('n4');
this.testNav.setRoot('login');
// this.app.getRootNav().setRoot('login');
//navCtrl.setRoot('login', null, null, () => { console.log('onDane') })
// navCtrl.setRoot('login');
}
}
Despite trying various approaches, none seem to be working. I am puzzled as to why the setRoot method is not being executed!!