Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic - How to remove sidemenu on login page only?

I need to remove sidemenu only on my login page. Otherwise remain. How it can be done? I'm using command ionic ionic start myApp sidemenu to create the project.

app.js

.config(function($stateProvider, $urlRouterProvider) {
  $stateProvider

    .state('login', {
      url: "/login",
      templateUrl: "templates/login.html",
      controller: 'LoginCtrl'
    })

    .state('app', {
      url: "/app",
      abstract: true,
      templateUrl: "templates/menu.html",
      controller: 'AppCtrl'
    })

    .state('app.search', {
      url: "/search",
      views: {
        'menuContent' :{
          templateUrl: "templates/search.html"
        }
      }
    })

login page

<ion-view title="Login">
  <ion-content>
      <div class="list">
        <label class="item">
          <button class="button button-block button-positive" type="submit" ng-click="login()">Log in</button>
        </label>
      </div>

  </ion-content>
</div>
like image 820
Nurdin Avatar asked Aug 06 '14 16:08

Nurdin


3 Answers

You can disable/enable sidemenu at any time at any page by calling

$ionicSideMenuDelegate.canDragContent(false)

e.g:

angular.module('ABC').controller('xyzCtrl', function($scope, $ionicSideMenuDelegate) {

    $ionicSideMenuDelegate.canDragContent(false)

});
like image 53
waqas Avatar answered Sep 23 '22 17:09

waqas


**Ionic 2**


    import { MenuController } from 'ionic-angular';

    export class LoginPage {

       constructor(public menuCtrl: MenuController) {

       }

       ionViewWillEnter() {

           this.menuCtrl.swipeEnable( false )
       }

       ionViewDidLeave() {

           this.menuCtrl.swipeEnable( true )
       }
    }



IONIC 4: Sept2019
try this code to in your login.page.ts
Step1: import {  MenuController } from '@ionic/angular';
Step2: constructor(public menuCtrl: MenuController) { }
(below constructo)
Step3: ionViewWillEnter() {
          this.menuCtrl.enable(false);
       }
       ionViewDidLeave() {
          this.menuCtrl.enable(true);
       } 

this code will help you to work with side menu flawlessly on any screen, if you login & re-login and try it will work now. 
like image 22
Luckylooke Avatar answered Sep 21 '22 17:09

Luckylooke


same issue here. just add hide-nav-bar="true" to the ion-view

<ion-view hide-nav-bar="true">

Hope it helps!

like image 21
Braian Mellor Avatar answered Sep 24 '22 17:09

Braian Mellor