Force ionic sidemenu to do pop instead setRoot

Hi guys, i’ve a mobile app and this haven’t a home screen, then i would like to set the navigation to two pages using navCtrl.pop instead navCtrl.setRoot…

How can i achieve this?

Thanks in advance

Hey @temohpab. Can you elaborate what you want to achieve? It’s difficult to understand your target

I have a sidemenu and if i click into an element of the sidemenu and then the back button is pressed the app exits… But i need to come back to the previous page, not leave the app

It’s the sidemenu click doing a navCtrl.setRoot() ?

Yep. @temohpab basically sidemenu’s on click function set your pressed page/button to root. You can achieve your desired results by changing it to


1 Like

Ok, this is a partial solution because now i can click in the sidemenu two times (or multiple times) in the same page and have a big stack of pages… How can i prevent to stack multiple pages? There are a limit or some logic to prevent this?

@temohpab Have no idea about that because basically side menus are used to set starting points for a long process or easy access. I showed menu on just my index/main page and on the other pages just a back button. So user won’t be able to push multiple pages. If he has to navigate to another option then he has to get back to index page. This served me the purpose :slight_smile:

Think on twitter for example… If you click in a sidemenu element you can go back to the previous page (and doesn’t exit from the app).

That’s the behaviour i want

Try adding the below code it may help.

Add this to your import list.
import { App } from 'ionic-angular';

This in your constructor.
constructor(public app: App)