Use nav.push with sidebar in ionic 2

I am trying to make a small application in ionic2to find out about this, but I have a navigation problem.

In fact, I understand well the difference between rootpage(change whit nav.setRoot) and the "normal" page (add with nav.push). The fact is that for my application I will need to open the side menu (this is normal if I am on rootpage, but do not completely disagree with the second type of page) and to return (this is normal using a push page, but not with the root page )

So, for me, this page type should be a click, not a root page, but how to display the side menu on this page type?

Thank.

+4
source share
1 answer

EDIT:

How about using persistent="true"in your item ion-menu? As you can see in the Ionic2 docs:

Persistent menus Persistent menus display the MenuToggle button in the NavBar on all pages in the navigation stack. To make the menu persistent, set the item to a constant value of true. Please note that this will only affect the MenuToggle button in the NavBar connected to the menu with a constant value of true, any other MenuToggle buttons will not be affected.

So your app.htmlwoul:

<ion-menu [content]="content" persistent="true">

  <ion-toolbar>
    <ion-title>Pages</ion-title>
  </ion-toolbar>

  <ion-content>
    <ion-list>
      <button menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)">
        {{p.title}}
      </button>
      <button menuClose ion-item (click)="logout()">Logout</button>
    </ion-list>
  </ion-content>

</ion-menu>

<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>
+11
source

All Articles