Ionic-framework: Tab rootParams not getting updated

Created on 22 Nov 2016  路  8Comments  路  Source: ionic-team/ionic-framework

Ionic version: (check one with "x")
[ ] 1.x
[X] 2.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:

When using ion-tabs and rootParams, if rootParams is being updated after the first initializations the page that is being entered doesn't get the updated params
Expected behavior:

Expected that the params on the new page will be up to date

Steps to reproduce:

Related code:

<ion-tabs (ionChange)="tabSwitched()">
  <ion-tab [root]="page1" [rootParams]="data" tabTitle="ionic" tabIcon="ionic"></ion-tab>
  <ion-tab [root]="page2" tabTitle="other" tabIcon="close"></ion-tab>
</ion-tabs>
  data = 0
  tabSwitched() {
    this.data += 1;
    console.log("Now data is: " + this.data + " Expected this on ionic page")
  }
  data
  ionViewDidEnter() {
    this.data = this.navParams.data
  }

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
Your system information:

Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.12
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.45
ios-deploy version: Not installed
ios-sim version: Not installed
OS: macOS Sierra
Node Version: v6.9.1
Xcode version: Xcode 8.1 Build version 8B62

stale issue

Most helpful comment

But it looks like using navParams.get('data') works if you use an object and then mutate the object. In your case @royipressburger I'd do:

data = {count: 0};
tabSwitched() {
    this.data.count++;
    console.log("Now data is: " + this.data + " Expected this on ionic page");
}
data;
ionViewDidEnter() {
    this.data = this.navParams.get('data');
}

All 8 comments

Amm any ideas? Workaround?

after looking more into this problem I can be more specific.
The problem is that once the page was loaded for the first time it looks like that the load() method of tab doesn't take params into consideration. see https://github.com/driftyco/ionic/blob/master/src/components/tabs/tab.ts#L306

Amm any comment?

I'm experiencing the same issue with latest release (RC4).

But it looks like using navParams.get('data') works if you use an object and then mutate the object. In your case @royipressburger I'd do:

data = {count: 0};
tabSwitched() {
    this.data.count++;
    console.log("Now data is: " + this.data + " Expected this on ionic page");
}
data;
ionViewDidEnter() {
    this.data = this.navParams.get('data');
}

@rolandjitsu Thanks thats solve the issue.. Tho this looks like a bit hacky :)
Still Ill be glad if one of the guys from ionic can confirm that :)

Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Thank you for using Ionic!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alan-agius4 picture alan-agius4  路  3Comments

alexbainbridge picture alexbainbridge  路  3Comments

brandyscarney picture brandyscarney  路  3Comments

gio82 picture gio82  路  3Comments

SebastianGiro picture SebastianGiro  路  3Comments