I have the following error with my code:
Cannot read property 'setRoot' of undefined
When setTimeout()
is removed, the code works fine. I can't understand why this is happening though nav
is properly defined.
export class LoginStudentPage {
constructor(public nav: NavController, public loadingCtrl: LoadingController) {
this.loading = this.loadingCtrl.create();
}
loading: any;
goToDiary(child){
this.storage.set('regNo', child);
this.loading.present();
setTimeout(function(){
this.nav.setRoot(TabsNavigationPage);
this.loading.dismiss();
}, 1500);
}
}