My problem:
My application contains a menu which is swipe enabled. On login screen if I swipe I can see the menu which is not right. I want to disable menu swipe for pages that doesn't contains menu icon, like login, inner details pages containing back button, etc.
Solution found:
I am able to do that by following the SO link - https://stackoverflow.com/a/38654644/2193918
I created a base class and injected a menu object in it. Override ionViewDidEnter()
and ionViewDidLeave()
In sub class, I inherited the base class. I have to write super()
call in derived class constructor and pass the menu object back to the super class.
Is their any other way of doing it as with this way I will have to do this in every single page.
Please check the snippet of code as below:
Base class
import { MenuController } from "ionic-angular";
export class BaseComponent {
constructor(public menu: MenuController) {
}
ionViewDidEnter() {
this.menu.swipeEnable(false);
}
ionViewDidLeave() {
this.menu.swipeEnable(true);
}
}
Derived class
import { Component } from '@angular/core';
import { NavController, LoadingController, Events, MenuController } from 'ionic-angular';
@Component({
selector: 'login',
templateUrl: 'login.component.html'
})
export class login extends BaseComponent {
constructor(public menu: MenuController) {
super(menu)
}
}