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

前端 未结 2 1124
日久生厌
日久生厌 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条回答
  •  萌比男神i
    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`);
    

提交回复
热议问题