# Closing a modal together with its navigation stack

**URL:** <https://forum.ionicframework.com/t/closing-a-modal-together-with-its-navigation-stack/62597>\
**Category:** ionic-v3\
**Created:** [September 5, 2016, 1:46pm UTC](https://forum.ionicframework.com/t/closing-a-modal-together-with-its-navigation-stack/62597 "2016-09-05T13:46:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![crkvend](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@crkvend](https://forum.ionicframework.com/u/crkvend)\
**Post date:** [September 5, 2016, 1:46pm UTC](https://forum.ionicframework.com/t/closing-a-modal-together-with-its-navigation-stack/62597/1 "2016-09-05T13:46:06Z")

</div>

Hi,

In some of the previous betas of Ionic 2, if you opened a modal and then pushed new pages from that modal, you could from any of those pages call `nav.popToRoot()` and it would reset that navigation stack and close the modal.

However, now in beta 11 (and perhaps earlier betas as well), if I call popToRoot() from one of those pushed pages, the stack is reset back to the modal, but the modal is not closed.

Is there a way to close the modal together with all its “children pages”, preferably with the same animation as when the modal closes?

Thanks!

---

<div class="post-metadata">

**Author:** ![crkvend](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@crkvend](https://forum.ionicframework.com/u/crkvend)\
**Post date:** [September 6, 2016, 8:05am UTC](https://forum.ionicframework.com/t/closing-a-modal-together-with-its-navigation-stack/62597/2 "2016-09-06T08:05:25Z")

</div>

I hope it’s ok if I bump this.

---

<div class="post-metadata">

**Author:** ![crkvend](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@crkvend](https://forum.ionicframework.com/u/crkvend)\
**Post date:** [September 11, 2016, 10:17pm UTC](https://forum.ionicframework.com/t/closing-a-modal-together-with-its-navigation-stack/62597/3 "2016-09-11T22:17:10Z")

</div>

One last go. I still haven’t found a nice way to do this.

Right now, I’m closing the stack like this:

```
  this.nav.popToRoot()
    .then(() => this.nav.first().dismiss());

```

It works but I would like to avoid the animation happening in two steps. First the pages animate horizontally on pop, and then, the modal animates vertically. Ideally, the entire stack should should animate vertically in just one step, just like it all was a part of the initial modal.

---

<div class="post-metadata">

**Author:** ![mrhirsch](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@mrhirsch](https://forum.ionicframework.com/u/mrhirsch)\
**Post date:** [November 24, 2016, 4:24pm UTC](https://forum.ionicframework.com/t/closing-a-modal-together-with-its-navigation-stack/62597/4 "2016-11-24T16:24:40Z")

</div>

I’m having the same issue. I have a modal that I’m adding pages to, and would like to close the modal on the last page when a user clicks a button.

Your solution was the exact same one that I thought of, and seems to be the only one that works. It seems you can only dismiss the modal view from the modal view controller. Calling dismiss on any pages added will only animate backwards in the stack.

Calling dismiss on the modal view while other pages are in the stack doesn’t work either.
