Setting root and passing parameters using the same function in angular 2
I am creating an Ionic2 app. On click, I submit the parameter and set a new rootPage in the same function so that I can display a different set of tabs on the landing page.
viewProjects(item){
this.navCtrl.push(ItemPage,{
item: item
});
this.navCtrl.setRoot(Tabs2Page);
}
Template:
<button ion-item (click)="viewItem(item)"> Item </button></div>
If I don't send the parameter on click, I can successfully navigate to the landing page and install a new rootPage.
viewProjects(item){
this.navCtrl.push(ItemPage);
this.navCtrl.setRoot(Tabs2Page);
}
If I only send the parameter and not setRoot, it works, I have access to the parameters I need, but the new rootPage is not set, so I have no tabs on the page.
viewProjects(item){
this.navCtrl.push(ItemPage,{
item: item
});
}
I am getting the following error
Runtime Error
Error in ./ItemPage class ItemPage - caused by: Cannot read property 'name' of undefined
I need to be able to setRoot and be able to send parameters on click, any idea how I can do this? Many thanks!
+3
source to share
No one has answered this question yet
Check out similar questions: