如何在ionic2中打开sidemenu时触发功能

时间:2020-12-01 23:00:42

I need trigger a function when SideMenu is open.I searched for this and got this link https://forum.ionicframework.com/t/possible-to-trigger-expression-on-opening-sidemenu/4381 for ionic-1 but how can I achieve this in ionic 2 ? Thanks in advance.

当SideMenu打开时,我需要触发一个函数。我搜索了这个并获得了这个链接https://forum.ionicframework.com/t/possible-to-trigger-expression-on-opening-sidemenu/4381 for ionic-1但是我怎样才能在离子2中实现这一目标?提前致谢。

1 个解决方案

#1


0  

You have to inject MenuController in your page, and then you can access the isOpen() method.

您必须在页面中注入MenuController,然后才能访问isOpen()方法。

    import{Page, MenuController} from 'ionic-angular';

    @Page({...})
    export class MyPage {

     constructor(private menu: MenuController) {
     if menu.isOpen() {
        // do something

 }

#1


0  

You have to inject MenuController in your page, and then you can access the isOpen() method.

您必须在页面中注入MenuController,然后才能访问isOpen()方法。

    import{Page, MenuController} from 'ionic-angular';

    @Page({...})
    export class MyPage {

     constructor(private menu: MenuController) {
     if menu.isOpen() {
        // do something

 }