javascript 如何禁用离子侧菜单上的拖动功能?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26731903/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you disable the drag function on an ionic side menu?
提问by Garrett
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:
Javascript:
$scope.$root.canDrag = false;
回答by Manish Kr. Shukla
Drag-content attribute must be written over tag.
Drag-content 属性必须写在标签上。
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.
要创建菜单关闭按钮,请将属性menu-toggle="menu_side" 添加到按钮。
E.g
例如
<button menu-toggle="right" class="button transparent button-icon icon ion-navicon"></button>
回答by Anjum....
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)
}
}());