如何检测侧面菜单是否在离子2中打开/关闭?
我正在使用我的离子2应用程序 cordova-google-maps
插件,我想在该页面上显示菜单(sidenav)。问题是sidenav正确接收事件我需要在打开sidenav时调用 map.setClickable(false)
并将其设置回 true
当用户关闭sidenav时。在使用打开
打开菜单时,似乎有一个事件要检查,但我不知道如何跟踪用户何时关闭菜单。
I am using cordova-google-maps
plugin with my ionic 2 app, and I want to show the menu (sidenav) on that page. Problem is for the sidenav to receive events properly I need to call map.setClickable( false )
while opening the sidenav and set it back to true
when the user closes the sidenav. It seems there is an event for checking while the menu is being opened with opening
, but I don't know how to track when the user closes the menu.
要在Ionic2中使用ionDrag,ionOpen,ionClose,你必须在菜单上添加它
For using ionDrag, ionOpen, ionClose in Ionic2 you must add it on the menu itself
例如,您的app.html文件中的修改菜单
for example modify menu in your app.html file by
<ion-menu [content]="content" (ionOpen)="menuOpened()" (ionClose)="menuClosed()">
使用事件后,请参阅此处的文档: http://ionicframework.com/docs/v2/api/util/Events/
After I use "Events" see doc here: http://ionicframework.com/docs/v2/api/util/Events/
如果菜单已关闭或打开,则在我的页面中进行检测。
For detect in my page if the menu was close or open.
我app.ts中的示例
Example in my app.ts
menuClosed() {
this.events.publish('menu:closed', '');
}
menuOpened() {
this.events.publish('menu:opened', '');
}
在我的其他页面中
events.subscribe('menu:opened', () => {
// your action here
});
events.subscribe('menu:closed', () => {
// your action here
});
我希望这有帮助