Hello,
I am trying to disable the side-menu in ionic 4 at the start of the appliaction execution. But it seems like the menu button is not available at that time. I tried to disable the button in the constructor method and in the ngAfterViewInit method but nothing is working. The only way I can disable the menu button is with a setTimeout of 1000ms or more. Bellow is the code that i am using.
Best regards Anže
const timer = (time: number) => {
return new Promise((resolve: any, reject: any) => {
setTimeout(_ => resolve(), time);
});
};
AppComponent implements AfterViewInit {
constructor(private menu: MenuController) {
}
async ngAfterViewInit() {
try {
await timer(1000); // fix for menu to work
const menus = await this.menu.getMenus();
await this.menu.enable(false);
console.log(menus);
} catch (err) {
console.log(err);
}
}
}
ionic (Ionic CLI) : 4.1.2 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.8
@angular-devkit/core : 0.7.5
@angular-devkit/schematics : 0.7.5
@angular/cli : 6.1.5
@ionic/ng-toolkit : 1.0.8
@ionic/schematics-angular : 1.0.6
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : none
Cordova Plugins : no whitelisted plugins (1 plugins total)
System:
Android SDK Tools : 26.1.1 (/Users/amatelic/Library/Android/sdk)
NodeJS : v10.9.0 (/usr/local/Cellar/node/10.9.0/bin/node)
npm : 6.2.0
OS : macOS High Sierra
Xcode : Xcode 9.4.1 Build version 9F2000