admin管理员组

文章数量:1278985

How do you disable the drag function on an ionic side menu? I am pretty new to this and need help. When I swipe right on the main page... it opens up a menu and I don't want this to happen. Here is my current code:

<!-- Side menu -->
<ion-side-menu side="left" drag-content="false">
<ion-header-bar class="bar-dark">
<h1 class="title">Cards</h1>
</ion-header-bar>
<ion-content scroll="true">
</ion-side-menus>

Javascript:

$scope.$root.canDrag = false; 

How do you disable the drag function on an ionic side menu? I am pretty new to this and need help. When I swipe right on the main page... it opens up a menu and I don't want this to happen. Here is my current code:

<!-- Side menu -->
<ion-side-menu side="left" drag-content="false">
<ion-header-bar class="bar-dark">
<h1 class="title">Cards</h1>
</ion-header-bar>
<ion-content scroll="true">
</ion-side-menus>

Javascript:

$scope.$root.canDrag = false; 
Share Improve this question asked Nov 4, 2014 at 9:41 GarrettGarrett 2613 gold badges7 silver badges16 bronze badges 1
  • You asked the same question before. Please remove it 1st. I suggest you also ask this question on Ionic Developer forum: forum.ionicframework. – Maxim Shoustin Commented Nov 4, 2014 at 9:48
Add a ment  | 

2 Answers 2

Reset to default 8

Drag-content attribute must be written over tag.

For e.g :

<ion-side-menu side="left">

      <ion-pane ion-side-menu-content drag-content="false">
           <ion-header-bar class="bar-dark">
               <h1 class="title">Cards</h1>
           </ion-header-bar>
           <ion-content scroll="true">
           </ion-content>
       </ion-pane> 

   </ion-side-menus>

This will do the job. !!

Edit :

To Create a Menu Close Button, add the attribute menu-toggle="menu_side" to the button.

E.g

<button menu-toggle="right" class="button transparent button-icon icon ion-navicon"></button>

You can disable drag side menu, for example on login page where you don't want side menu to be visible.

(function () {
'use strict';
angular
    .module('myApp')
    .controller('LoginCtrl', [
        '$scope',
        '$log',
        '$ionicSideMenuDelegate',
        LoginFunction]);

function LoginFunction($scope, $log, $ionicSideMenuDelegate) {
    var vm = this;

    $log.debug('its working');
    $ionicSideMenuDelegate.canDragContent(false)
}
}());

本文标签: javascriptHow do you disable the drag function on an ionic side menuStack Overflow