$ionicSideMenuDelegate

Delegate for controlling the ionSideMenus directive.

Methods called directly on the $ionicSideMenuDelegate service will control all side menus. Use the $getByHandle method to control specific ionSideMenus instances.

Usage

<body ng-controller="MainCtrl">
  <ion-side-menus>
    <ion-side-menu-content>
      Content!
      <button ng-click="toggleLeftSideMenu()">
        Toggle Left Side Menu
      </button>
    </ion-side-menu-content>
    <ion-side-menu side="left">
      Left Menu!
    <ion-side-menu>
  </ion-side-menus>
</body>
function MainCtrl($scope, $ionicSideMenuDelegate) {
  $scope.toggleLeftSideMenu = function() {
    $ionicSideMenuDelegate.toggleLeft();
  };
}

Methods

toggleLeft([isOpen])

Toggle the left side menu (if it exists).

Param Type Details
isOpen
(optional)
boolean

Whether to open or close the menu. Default: Toggles the menu.

toggleRight([isOpen])

Toggle the right side menu (if it exists).

Param Type Details
isOpen
(optional)
boolean

Whether to open or close the menu. Default: Toggles the menu.

getOpenRatio()

Gets the ratio of open amount over menu width. For example, a menu of width 100 that is opened by 50 pixels is 50% opened, and would return a ratio of 0.5.

  • Returns: float 0 if nothing is open, between 0 and 1 if left menu is opened/opening, and between 0 and -1 if right menu is opened/opening.

isOpen()

  • Returns: boolean Whether either the left or right menu is currently opened.

isOpenLeft()

  • Returns: boolean Whether the left menu is currently opened.

isOpenRight()

  • Returns: boolean Whether the right menu is currently opened.

canDragContent([canDrag])

Param Type Details
canDrag
(optional)
boolean

Set whether the content can or cannot be dragged to open side menus.

  • Returns: boolean Whether the content can be dragged to open side menus.

edgeDragThreshold(value)

Param Type Details
value boolean|number

Set whether the content drag can only start if it is below a certain threshold distance from the edge of the screen. Accepts three different values:

  • If a non-zero number is given, that many pixels is used as the maximum allowed distance from the edge that starts dragging the side menu.
  • If true is given, the default number of pixels (25) is used as the maximum allowed distance.
  • If false or 0 is given, the edge drag threshold is disabled, and dragging from anywhere on the content is allowed.
  • Returns: boolean Whether the drag can start only from within the edge of screen threshold.

$getByHandle(handle)

Param Type Details
handle string
  • Returns: delegateInstance A delegate instance that controls only the ionSideMenus directives with delegate-handle matching the given handle.

Example: $ionicSideMenuDelegate.$getByHandle('my-handle').toggleLeft();