mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
docs(MenuController): update MenuController docs
This commit is contained in:
@ -132,26 +132,74 @@ import {MenuType} from './menu-types';
|
|||||||
export class MenuController {
|
export class MenuController {
|
||||||
private _menus: Array<Menu> = [];
|
private _menus: Array<Menu> = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Progamatically open the Menu.
|
||||||
|
* @return {Promise} returns a promise when the menu is fully opened
|
||||||
|
*/
|
||||||
open(menuId?: string) {
|
open(menuId?: string) {
|
||||||
let menu = this.get(menuId);
|
let menu = this.get(menuId);
|
||||||
menu && menu.open();
|
if (menu) {
|
||||||
|
return menu.open();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Progamatically close the Menu.
|
||||||
|
* @param {string} [menuId] Optionally get the menu by its id, or side.
|
||||||
|
* @return {Promise} returns a promise when the menu is fully closed
|
||||||
|
*/
|
||||||
close(menuId?: string) {
|
close(menuId?: string) {
|
||||||
let menu = this.get(menuId);
|
let menu = this.get(menuId);
|
||||||
menu && menu.close();
|
if (menu) {
|
||||||
|
return menu.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle the menu. If it's closed, it will open, and if opened, it will
|
||||||
|
* close.
|
||||||
|
* @param {string} [menuId] Optionally get the menu by its id, or side.
|
||||||
|
* @return {Promise} returns a promise when the menu has been toggled
|
||||||
|
*/
|
||||||
|
toggle(menuId?: string) {
|
||||||
|
let menu = this.get(menuId);
|
||||||
|
if (menu) {
|
||||||
|
return menu.toggle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable or disable a menu. For example, there could be multiple
|
||||||
|
* left menus, but only one of them should be able to be dragged open.
|
||||||
|
* @param {boolean} shouldEnable True if it should be enabled, false if not.
|
||||||
|
* @param {string} [menuId] Optionally get the menu by its id, or side.
|
||||||
|
* @return {Menu} Returns the instance of the menu, which is useful for chaining.
|
||||||
|
*/
|
||||||
enable(shouldEnable: boolean, menuId?: string) {
|
enable(shouldEnable: boolean, menuId?: string) {
|
||||||
let menu = this.get(menuId);
|
let menu = this.get(menuId);
|
||||||
menu && menu.enable(shouldEnable);
|
if (menu) {
|
||||||
|
return menu.enable(shouldEnable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to enable or disable the ability to swipe open the menu.
|
||||||
|
* @param {boolean} shouldEnable True if it should be swipe-able, false if not.
|
||||||
|
* @param {string} [menuId] Optionally get the menu by its id, or side.
|
||||||
|
* @return {Menu} Returns the instance of the menu, which is useful for chaining.
|
||||||
|
*/
|
||||||
swipeEnable(shouldEnable: boolean, menuId?: string) {
|
swipeEnable(shouldEnable: boolean, menuId?: string) {
|
||||||
let menu = this.get(menuId);
|
let menu = this.get(menuId);
|
||||||
menu && menu.swipeEnable(shouldEnable);
|
if (menu) {
|
||||||
|
return menu.swipeEnable(shouldEnable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to get a menu instance.
|
||||||
|
* @param {string} [menuId] Optionally get the menu by its id, or side.
|
||||||
|
* @return {Menu} Returns the instance of the menu if found, otherwise `null`.
|
||||||
|
*/
|
||||||
get(menuId?: string): Menu {
|
get(menuId?: string): Menu {
|
||||||
if (menuId) {
|
if (menuId) {
|
||||||
// first try by "id"
|
// first try by "id"
|
||||||
|
@ -10,6 +10,9 @@ import {MenuController} from './menu-controller';
|
|||||||
import {MenuType} from './menu-types';
|
import {MenuType} from './menu-types';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ion-menu',
|
selector: 'ion-menu',
|
||||||
host: {
|
host: {
|
||||||
|
Reference in New Issue
Block a user