ionic Side Menu
A container element contains the side menu and the main content. By dragging the main content area from one side to the other, the left or right side menu is toggled.
The effect is shown below:
Usage
To use a side menu, add a parent element
function ContentController($scope, $ionicSideMenuDelegate) {
$scope.toggleLeft = function() {
$ionicSideMenuDelegate.toggleLeft();
};
}
API
| property | Type | Details |
|---|---|---|
| enable-menu-with-back-views |
(optional)
| `boolean` |When the back button is shown, confirm whether to enable the side menu.
| | delegate-handle | string | This handle is used to identify the scroll view with $ionicScrollDelegate. |ion-side-menu-content
A container of visible main content, with one or more ionSideMenu directives as siblings.
Usage
API
| property | Type | Details |
|---|---|---|
| drag-content |
(optional)
| `boolean` |Whether the content can be dragged. Default is true.
|ion-side-menu
A container for a side menu, with one ion-side-menu-content directive as a sibling.
Usage
API
| property | Type | Details |
|---|---|---|
| side | 字符串 |
Which side the side menu is currently on. Possible values: 'left' or 'right'. |
| is-enabled |
(optional)
| `boolean` |Whether this side menu is available.
| | widthHow many pixels wide the side menu should be. Default is 275.
|menu-toggle
Toggle the menu in a specified sidebar.
Usage
Below is an example of a link in the navigation bar. Clicking this link automatically opens the specified side menu.
...
menu-close
Close the currently open side menu.
Usage
Below is an example of a link in the navigation bar. Clicking this link automatically opens the specified side menu.
首页
$ionicSideMenuDelegate
This method directly triggers the $ionicSideMenuDelegate service to control all side menus. Use the $getByHandle method to control ionSideMenus in specific cases.
Usage
内容!
左侧菜单!
function MainCtrl($scope, $ionicSideMenuDelegate) {
$scope.toggleLeftSideMenu = function() {
$ionicSideMenuDelegate.toggleLeft();
};
}
Method
toggleLeft([isOpen])
Toggle the left side menu (if it exists).
| Parameters | Type | Details |
|---|---|---|
| isOpen |
(optional)
| `boolean` |Whether to open or close the menu. Default: toggle the menu.
|
toggleRight([isOpen])
Toggle the right side menu (if it exists).
| Parameters | Type | Details |
|---|---|---|
| isOpen |
(optional)
| `boolean` |Whether to open or close the menu. Default: toggle the menu.
|
getOpenRatio()
Get the ratio by which the opened menu content exceeds the menu width. For example, a menu 100px wide opened to 50% with a width of 50px returns a ratio of 0.5.
** Returns: ** float 0 means not opened; if the left menu is opened or opening, 0 to 1; if the right menu is opened or opening, 0 to -1.
isOpen()
** Returns: ** boolean, determining whether the left or right menu is already open.
isOpenLeft()
** Returns: ** boolean, whether the left menu is already open.
isOpenRight()
** Returns: ** boolean, whether the right menu is already open.
canDragContent([canDrag])
| Parameters | Type | Details |
|---|---|---|
| canDrag |
(optional)
| `boolean` |Set whether the content can be dragged to open the side menu.
|Return value: Boolean, whether the content can be dragged to open the side menu.
$getByHandle(handle)
| Parameters | Type | Details |
|---|---|---|
| handle | 字符串 |
For example:
$ionicSideMenuDelegate.$getByHandle('my-handle').toggleLeft();