Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic2 - Login and then Side menu

I am creating an App with Ionic2 and the requirement is - - the app when first loaded will show a Log In page and when logged in - will have a Side-Menu enabled pages

The starter project shows that the Side Menu as the root of the app and loads first before any other page is open - then it loads the other related pages.

How can I build an app that Loads Log In page first and then set the Side Menu as the main navigation and never shows up the Log In screen??

I did this with ionic 1 but not being able to figure out with ionic2

Please help.

like image 714
Arup Bhattacharya Avatar asked Dec 25 '22 05:12

Arup Bhattacharya


2 Answers

One solution would be to disable menu on Login screen and then to enable it after login.

You can disable menu by injecting MenuController and then use:

  import {NavController, MenuController} from 'ionic-angular';



  ionViewDidEnter() {
    //to disable menu, or
    this.menu.enable(false);
  }

  ionViewWillLeave() {
    // to enable menu.
    this.menu.enable(true);
}
like image 127
Boris Savic Avatar answered Feb 24 '23 04:02

Boris Savic


@Digital IQ, you have to set your login page as the rootPage in your existing app.ts file and use MenuController in login page to make menu enable onPageDidLeave. The example for this is available in ionic conference app where they have tutorial page before getting in to the actual application. Refer this for menu control and this (line 50) to set the initial page.

like image 45
AishApp Avatar answered Feb 24 '23 03:02

AishApp