Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disable menu on login page ionic 4

I use the beta of ionic 4 for the first time. I try to disable the menu on a login page, but i have some trouble.

I've created the app with ionic-cli and the sidemenu template, then I generated a login page.

I removed the <ion-split-pane> from the app.component.html

I modified the app-routing.module.ts to redirect to my login screen. In my login file, I tried to put an ngOnInit event to disable the menu on this specific page

import { Component, OnInit, AfterContentInit, AfterViewInit,OnDestroy } from '@angular/core';
import { MenuController } from '@ionic/angular';
@Component({
  selector: 'app-login',
  templateUrl: './login.page.html',
  styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit, AfterContentInit, AfterViewInit,OnDestroy {
  constructor(public menuCtrl: MenuController) {}
  ngOnInit() {
    this.menuCtrl.enable(false);
    this.menuCtrl.swipeEnable(false);
  }
  ngAfterContentInit()  {
    this.menuCtrl.enable(false);
    this.menuCtrl.swipeEnable(false);
  }
  ngAfterViewInit() {
    this.menuCtrl.enable(false);
    this.menuCtrl.swipeEnable(false);
  }
  ngOnDestroy() {
    this.menuCtrl.enable(true);
    this.menuCtrl.swipeEnable(true);
  }
}

I alto tried with an id set in ion-menu

<ion-menu swipeEnabled="true" #menu>

and change my code with

this.menuCtrl.enable(false, 'menu');

It's not working, can some one help me please.

Thank's

like image 351
JEKES Avatar asked Jul 31 '18 09:07

JEKES


People also ask

How do you turn off an ionic menu?

The MenuToggle component can be used to toggle a menu open or closed. By default, it's only visible when the selected menu is active. A menu is active when it can be opened/closed. If the menu is disabled or it's being presented as a split-pane, the menu is marked as non-active and ion-menu-toggle hides itself.

How do I hide side menu in ionic 4?

ion-menu-toggle The MenuToggle component can be used to toggle a menu open or closed. We'll place all navigation links inside the MenuToggle component. When a user taps on the link, the side menu will automatically be closed.


1 Answers

In my case in ionic 4 app, I did the following in welcome.page.ts file. welcome.page.ts is the page in which I want to hide split pane.

import {  MenuController } from '@ionic/angular';

constructor( public menuCtrl: MenuController){}

ionViewWillEnter() {
 this.menuCtrl.enable(false);
}
like image 135
Phan Hero Avatar answered Sep 28 '22 05:09

Phan Hero