Disable the side menu's swipe to open gesture for Login page (or any page) in Ionic 2

前端 未结 2 1120
日久生厌
日久生厌 2021-01-02 10:05

I\'m new to Ionic 2 & Angular2 and I have downloaded a new Ionic template with the following command

 Ionic start appname sidemenu --v2 --ts


        
相关标签:
2条回答
  • 2021-01-02 10:20

    I think the drag-content directive is used in ionic 1, for Ionic 2 what you can do is disable it from within your page class file.

    You can do this by importing the MenuController provider from ionic-angular and then call the .swipeEnable(shouldEnableBoolean, menuId) method to disable the swipe gesture within your page's class (this is also documented here).

    Your login controller should be something like this...

    import {Page, MenuController} from 'ionic-angular';
    
    @Page({
        templateUrl: 'build/pages/home/home.html'
    })
    export class HomePage {
        constructor(public menu: MenuController) {
            this.menu.swipeEnable(false);
        }
    }
    

    If you have multiple menus and each one has an id then you can target a specific menu like this...

    this.menu.swipeEnable(false, `menuId`);
    
    0 讨论(0)
  • 2021-01-02 10:30

    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)
    

    });

    0 讨论(0)
提交回复
热议问题