如何在离子侧菜单上禁用拖动功能?我是新手,需要帮助。当我在主页面上向右滑动时...它打开了一个菜单,我不希望这种情况发生。这是我目前的代码:
<!-- 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;
答案 0 :(得分:8)
Drag-content属性必须写在标签上。
例如:
<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>
这将完成这项工作。 !!
编辑:
要创建菜单关闭按钮,请将属性 menu-toggle =&#34; menu_side&#34; 添加到按钮。
E.g
<button menu-toggle="right" class="button transparent button-icon icon ion-navicon"></button>
答案 1 :(得分:1)
您可以禁用拖动侧面菜单,例如在您不希望侧面菜单可见的登录页面上。
(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)
}
}());