Can i pass parameter values through various pages?

My main issue is because I’m using superTabsModule, i have a page to the superTabs (HomePage), and others pages to insert data, well if i send the parameters to a specific page something like this shows up:

Although the view i want to get is something like this:

The code i use to pass parameters is this:

    this.navCtrl.push(HomePage, {id : id});
    return console.log('id: ',id);


My question is if there’s a way so send the parameter (id) to all the other pages or a better method??

Thanks in advance!

Use a service instead while these datas are shared datas.

i was seeing an example from that right know, but get the id from clicking in the ion-item

You could use ionic-storage to get and set values just as you would with local storage. These are persistent though so can even survive through killing the app. This is good if you want to access the data across multiple pages and you can even bind objects. If you are only wanting to pass an ID between one page, the method you implemented above is correct.

See: Ionic Storage Docs for more information on how to get started. You won’t need SQLite though unless you want to make things more complex.

Then set the item using the following:'idNameForQuickReference',id); 

and you can get that same item across multiple pages with:'idNameForQuickReference').then(val => { console.log('Your ID is ' + val) });

You can even store objects if you want multiple ID’s.

I disagree with the advice in the previous post, and think storage should only be used to persist across app quit/restart, for three reasons:

  • it is extremely easy to bite yourself with insidious race conditions, and the code necessary to protect against them is tricky and error-prone
  • it is less performant than simply using Observables in a provider or NavParams
  • in many if not most cases, you don’t want this data to persist across app restarts, so now you have to write extra needless initialization code to clear it out at app startup
1 Like