Reputation: 31
I need to implement a logic same as given in the below link: ionic 2 sidemenu - navCtrl inside a component
I have ion-nav in app.ts & within the app.html there is another custom component(menu.ts). From inside the menu.ts, I want to navigate/set another component as root
I am getting error Cannot read property 'setRoot' of undefined
How can I pass nav from app.ts to the menu component?
Upvotes: 0
Views: 663
Reputation: 731
You can pass parameters to pages like this:
this.nav.setRoot(page.component, nav);
and afterwards read them with:
constructor(public params: NavParams) {
this.nav= params.get('nav');
}
But this shouldn't be necessary when you want to call "setRoot" I do it like this:
constructor(public navCtrl: NavController) {
}
....
navigateToPage() {
this.navCtrl.setRoot(Page);
}
Upvotes: 0