ionic-framework: rootParams in ion-nav not returning data
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:
Passing data in rootParams Expected behavior:
Return data
Related code: Page 1: this.test = {x: ‘For Testing’};
<ion-nav [root]="rootPage" [rootParams]="test"></ion-nav>
Page 2: console.log(this.navParams); // no return data or console.log(this.navParams.get(‘x’)); // no return data
Ionic info: System information: Cordova CLI: 6.4.0 Ionic Framework Version: 2.0.0-rc.4 Ionic CLI Version: 2.1.17 Ionic App Lib Version: 2.1.7 Ionic App Scripts Version: 0.0.47 ios-deploy version: Not installed ios-sim version: Not installed OS: Windows 7 Node Version: v6.9.1 Xcode version: Not installed
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 11
- Comments: 17 (5 by maintainers)
this is happening to me as well…
This is still an issue in Ionic 3.0.1 I found that the rootParams are available in NavController instance, but
rootParam
property is missing in the typing. This works:(navCtrl as any).rootParams
What helped me was to move my
this.navParams
out of the constructor function and into the ngOnInit() function.@danielsogl @manucorporat instead of setting
rootPage
, I’m using following code and it works.this.appCtrl.getRootNav().setRoot(root, { myParams: someParamsObject });
Let me know if it’s the good solution.
Hi @warent since it’s still not working, I tried in this doc http://ionicframework.com/docs/v2/api/navigation/NavController/ the Navigating from the Root component . Maybe this can help you too.
@amirhammad: i have a similar issue: it’s working fine the first time. but if you change the value
rootPage
it fails.step 1: set
selectedTab
to some valueT1
withparam = P1
- everything works fine step 2: change the value ofselectedTab
, say toT2
step 3: change the value ofselectedTab
back toT1
. -NavParams
in the component is empty ({}
) because it calls change on root ignoring the params.