Issue
When I navigate from my dashboard ion menu to Login screen and after successfully logged in when I am trying to open ion menu again it automatically closed and got this error.
Ionic:
Ionic CLI : 5.4.16 (/usr/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 5.6.3
@angular-devkit/build-angular : 0.803.29
@angular-devkit/schematics : 8.3.29
@angular/cli : 8.3.29
@ionic/angular-toolkit : 2.3.3
Cordova:
Cordova CLI : 9.0.0 ([email protected])
Cordova Platforms : android 8.1.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 20 other plugins)
Utility:
cordova-res (update available: 0.15.3) : 0.14.0
native-run : 1.3.0
System:
NodeJS : v10.24.0 (/usr/bin/node)
npm : 6.14.11
OS : Linux 5.4
Thank you
Solution
It seems this issue is originated by the misuse of Ionic page life cycle events. If a page wants to hide the side menu, it should disable the menu on the ionViewDidEnter event (fired when the component routing to has finished animating) instead of relying on the ngOnInit or ionviewwillenter. Also it should clean itself and enable the menu again in the ionViewDidLeave event.
The code should look something like this
constructor(public menu: MenuController) { }
ionViewDidEnter(): void {
this.menu.enable(false);
}
ionViewDidLeave(): void {
this.menu.enable(true);
}
Answered By - Vaibhav Shah
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.