I dont want to execute code inside
ngOnInit() {
console.log("done");
}
so i want to go back to another page before that through
ionViewWillEnter(){
this.navCtrl.goRoot('/login');
}
i m able to go to that page but still can see “done” text
i did this also but not working
ionViewWillEnter(): boolean{
return false;
}
spontaneously, if I may, too me it sounds like a bad pattern to navigate in a page ngOnInit
or ionViewWillEnter
no? so you gonna display the user for a couple of milliseconds and then the page change automatically?
then what to do? i saw that ngOnInit() fired first then ionViewWillEnter(). so i did like this:
ionViewWillEnter(){
//page access
this.dataProvider.accessControl().then((response) => {
if(response == true){
console.log("done");
}else{
this.navCtrl.goRoot('/login');
}
});
}
any other way? here accessControl checking storage that user is logged in or not.
I would use a Subject
or BehaviorSubject
in your provider and subscribe to it in app.component
where I would actually trigger the redirect to root if the user hasn’t the right to navigate
yep, good option. i will try this too 