Navigation within Child View using Side Menu

Here is a reference code. I am using the menu.

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


      <button menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)">
      <button menuClose ion-item (click)="logout()">Logout</button>


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

What should the openPage(p) function look like if I want to change the root in the ion-nav instead on pushing another page on the navigation stack? How do I pass in params in such a situation?

PS: I want to keep the sidemenu intact, just want to close it and load a new page in the menu’s content along with some parameters.

Presumably you’ve injected NavController in the component that is providing openPage, so it would look like:

let np = p.params ? p.params : {};
this.nav.setRoot(p.component, np);

What I wanted was to tap on the menu and change the child view. So I cannot use push or setRoot on the primary navCtrl. I had to get a reference to Child View.

export class MenuPage {
    @ViewChild('mycontent') childNavCtrl: NavController;

And then on button tap,

this.childNavCtrl.setRoot(ProductsByCategoryPage, {"category": category});


i use the same code also but there is a bit bug i think.

@ViewChild('content') childNavCtrl: NavController;

openCategoryPage(category) {

    this.childNavCtrl.setRoot('ProductsByCategory', { "category": category });
    console.log('end opencategory function');

products-by-category page stays empty after the page is loaded i can see it in console categorys are printed.

but when i resize the window or click on the menu its load ui?

what is here the problem i’m looking days for it.

thank by advance.


Please post your question in the QnA Section on Udemy.

i posted my question on Udemy also

thank you