If a `menuId` is not provided then it'll return the first menu found.
If a `menuId` is `left` or `right`, then it'll return the enabled menu
on that side. Otherwise, if a `menuId` is provided, then it'll try to
find the menu using the menu's `id` property. If a menu is not found
then it'll return `null`. If a menu id was provided, but was not found,
it will not fallback to finding any menu. Closes#5535
Menu has been improved to make it easier to open, close, toggle and
enable menus.
Instead of injecting `IonicApp` to find the menu component, you now
inject
`MenuController`.
Was:
```
constructor(app: IonicApp) {
this.app = app;
}
openMenu() {
this.app.getComponent('leftMenu').close();
}
```
Now:
To programmatically interact with any menu, you can inject the
`MenuController`
provider into any component or directive. This makes it easy get ahold
of and
control the correct menu instance. By default Ionic will find the app's
menu
without requiring a menu ID. An id attribute on an `<ion-menu>` is only
required
if there are multiple menus on the same side. If there are multiple
menus, but
on different sides, you can use the name of the side to get the correct
menu
If there's only one menu:
```
constructor(menu: MenuController) {
this.menu = menu;
}
openMenu() {
this.menu.close();
}
```
If there is a menu on the left and right side:
```
toggleMenu() {
this.menu.toggle('left');
}
```
If there are multiple menus on the same side:
```
<ion-menu id="myMenuId" side="left">...</ion-menu>
<ion-menu id="otherMenuId" side="left">...</ion-menu>
closeMenu() {
this.menu.close('myMenuId');
}
```
Improved which angles should allow the side menu to open, depending if
it’s a left or right menu. Also check if the distance of the drag is
longer than a side menu would get. For example, scrolling vertically
for a long ways would have a long distance, but triggering a side menu
to open would be a short distance.
Also ensure that a side menu can always be closed incase something goes
wrong.
Closes#5272