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
angular ionic2


source to share


No one has answered this question yet

Check out similar questions:

378
Angular digital input error - EXCEPTION: Cannot resolve all parameters
283
Angular - setting headers for every request
13
How to choose tabs in ionic 2?
6
Ionic 2 - Sidebar with navigation between pages (back button)
2
The advantage of using ionic2 ionViewCanLeave Navigationguard is to react to alert to stay or leave the page
1
Runtime error caused by: Unable to read property name of undefined
0
After successful login
0
pass variable when clicking an element from one page to another in ionic2
0
Ionic2 - setRoot on logout / login crashes navigation
0
Sidebar not loading pages



All Articles
Loading...
X
Show
Funny
Dev
Pics