Typescript ionic 3 add call to all constructors
1 answer
I suggest having a class BaseComponent
that implements ionViewCanEnter
that returns a boolean.
Runs before the view appears. This can be used as a kind of "security" on authenticated views where you need to check permissions before the view can enter
export class BaseComponent{
constructor(){}
ionViewCanEnter(){
//check if logged in or not and return the boolean value
}
}
This component can be extended by all of your pages.
export class MyPage extends BaseComponent{
//...
}
You can try to call yours this.appCtrl.redirectIfNotLogedIn();
in the BaseComponent constructor, but I suggest you use NavGuard.
+1
source to share