# Menu events how handle change

**URL:** <https://forum.ionicframework.com/t/menu-events-how-handle-change/58631>\
**Category:** ionic-v3\
**Created:** [July 26, 2016, 11:40am UTC](https://forum.ionicframework.com/t/menu-events-how-handle-change/58631 "2016-07-26T11:40:08Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ludovicevrard](https://avatars.discourse-cdn.com/v4/letter/l/bb73d2/32.png) [@ludovicevrard](https://forum.ionicframework.com/u/ludovicevrard)\
**Post date:** [July 26, 2016, 11:40am UTC](https://forum.ionicframework.com/t/menu-events-how-handle-change/58631/1 "2016-07-26T11:40:08Z")

</div>

Hi,

I have made many search but I can’t find how handle change when the open openning or closing. I have found Output Events for components menu: ionOpen, ionClose and ionDrag here: [http://ionicframework.com/docs/v2/api/components/menu/Menu/#output-events](http://ionicframework.com/docs/v2/api/components/menu/Menu/#output-events)

But they have no documentation how can I add lisener or subscribe to this event.

Thanks for you help.

---

<div class="post-metadata">

**Author:** ![william\_harris](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/william_harris/32/101865_2.png) [@william\_harris](https://forum.ionicframework.com/u/william_harris)\
**Post date:** [July 26, 2016, 11:57am UTC](https://forum.ionicframework.com/t/menu-events-how-handle-change/58631/2 "2016-07-26T11:57:28Z")

</div>

In your `app.html` file

`<ion-menu [content]="content" (ionOpen)="menuOpened()" (ionClose)="menuClosed()" >`

And then in your `app.ts` file you write your event handler functions

```
menuClosed() {
      //code to execute when menu has closed
}

menuOpened() {
     //code to execute when menu ha opened
}
```

---

<div class="post-metadata">

**Author:** ![ludovicevrard](https://avatars.discourse-cdn.com/v4/letter/l/bb73d2/32.png) [@ludovicevrard](https://forum.ionicframework.com/u/ludovicevrard)\
**Post date:** [July 26, 2016, 12:15pm UTC](https://forum.ionicframework.com/t/menu-events-how-handle-change/58631/3 "2016-07-26T12:15:25Z")

</div>

Hi, thanks you for you fast reply!

It’s work well, i’ve just add Events from ‘ionic-angular’ and change code by:

```
menuClosed() {
    this.events.publish('menu:closed', '');
}

menuOpened() {
    this.events.publish('menu:opened', '');
}

```

And get him on other page…

Thanks you for you help you save my day!

---

<div class="post-metadata">

**Author:** ![william\_harris](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/william_harris/32/101865_2.png) [@william\_harris](https://forum.ionicframework.com/u/william_harris)\
**Post date:** [July 26, 2016, 1:01pm UTC](https://forum.ionicframework.com/t/menu-events-how-handle-change/58631/4 "2016-07-26T13:01:39Z")

</div>

That was my solution too, using the Ionic Events class. Glad to help

---

<div class="post-metadata">

**Author:** ![redgeb](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@redgeb](https://forum.ionicframework.com/u/redgeb)\
**Post date:** [August 4, 2016, 10:27pm UTC](https://forum.ionicframework.com/t/menu-events-how-handle-change/58631/5 "2016-08-04T22:27:37Z")

</div>

Just to save anyone else the time that I wasted, the (ionOpen), (ionClose) and (ionDrag) events were implemented in beta 8. So don’t waste time wondering why they won’t work if you aren’t using 8 or above 😃

(Btw if you aren’t using version 7, you can use the (opening) event explained [here](http://ionicframework.com/docs/v2/2.0.0-beta.7/api/components/menu/Menu/).)

---

<div class="post-metadata">

**Author:** ![sonicwong78](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sonicwong78](https://forum.ionicframework.com/u/sonicwong78)\
**Post date:** [August 14, 2017, 8:46am UTC](https://forum.ionicframework.com/t/menu-events-how-handle-change/58631/6 "2017-08-14T08:46:58Z")

</div>

“menuOpened” called, but when I updated some variable inside this method.  
There is no update on menu (eg: load user name from my own provider and display it on side menu).  
When I close the side menu, the variable being updated on UI.

May I know how to force update the menu ui? Thanks!

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [August 14, 2017, 9:26am UTC](https://forum.ionicframework.com/t/menu-events-how-handle-change/58631/7 "2017-08-14T09:26:55Z")

</div>

> [@sonicwong78](#):
>
> May I know how to force update the menu ui?

In my experience, any time I want to “force” something when programming, one of two things happens.

A. I figure out a way to “force” it, and six weeks later I hate myself.  
B. I take a deep breath, pet my cat, rethink what I am really trying to do, and realize that “force” is antithetical to how I want to live my life.

Your move.

---

<div class="post-metadata">

**Author:** ![sonicwong78](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sonicwong78](https://forum.ionicframework.com/u/sonicwong78)\
**Post date:** [August 21, 2017, 1:42am UTC](https://forum.ionicframework.com/t/menu-events-how-handle-change/58631/8 "2017-08-21T01:42:31Z")

</div>

Hope I have time to hate myself finally…

`this.changeDetectorRef.detectChanges();`

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [August 21, 2017, 2:01am UTC](https://forum.ionicframework.com/t/menu-events-how-handle-change/58631/9 "2017-08-21T02:01:37Z")

</div>

I don’t think manual change detection should be necessary here.

---

<div class="post-metadata">

**Author:** ![kurpav](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@kurpav](https://forum.ionicframework.com/u/kurpav)\
**Post date:** [May 11, 2018, 12:49pm UTC](https://forum.ionicframework.com/t/menu-events-how-handle-change/58631/10 "2018-05-11T12:49:09Z")

</div>

Any other solutions?

---

<div class="post-metadata">

**Author:** ![ManigandanRaamanatha](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/manigandanraamanatha/32/119596_2.png) [@ManigandanRaamanatha](https://forum.ionicframework.com/u/ManigandanRaamanatha)\
**Post date:** [May 23, 2018, 5:19pm UTC](https://forum.ionicframework.com/t/menu-events-how-handle-change/58631/11 "2018-05-23T17:19:34Z")

</div>

Yes, you can alternatively use custom event instead of predefined. Use events by subscribing to an event from other pages and listen for that events to occur through the constructor of the page that you wanted to perform changes.

---

<div class="post-metadata">

**Author:** ![GoTop](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/gotop/32/123661_2.png) [@GoTop](https://forum.ionicframework.com/u/GoTop)\
**Post date:** [March 7, 2019, 4:38pm UTC](https://forum.ionicframework.com/t/menu-events-how-handle-change/58631/12 "2019-03-07T16:38:25Z")

</div>

> [@william\_harris](#):
>
> (ionOpen)=“menuOpened()”

instead of menuOpened we now have these options 🙂

| `ionDidClose ` | Emitted when the menu is closed. |
| --- | --- |
| `ionDidOpen` | Emitted when the menu is open. |
| `ionWillClose` | Emitted when the menu is about to be closed. |
| `ionWillOpen` | |
