Best practice for transferring state between pages in Ionic 2?

Good day,

I’m confused that I can’t dynamically pass parameters into JS method calls via interpolation. How is state conveyed between pages in Ionic 2?

Hi,

you can do this with events/subscribabels or you pass the variable with the navCtrl.push to the next view. And in the new view you get it from the NavParams.get(‘param’);

Hi,

you could try something like ngrx store for state management. Easier than pass state around, i think.

Good day. Thanks for your response. You are referring to this, right? How would I pass the variable from the template? I tried this with interpolation and failed because it seems it’s not what interpolation is for.

Hi @nachtwandler,
I’ll look more closely, thanks. I’m a bit worried that it’s named as if it’s built for rx :confused:

Hi @siphiwe,
why are you worried about that? Yes, it’s build on top of rxjs and observables.

@nachtwandler, my apologies, I’m only just reading about rxjs and state management now and realizing that that’s probably the most direct answer to my question. I had no idea that Ionic/Angular don’t exactly handle this. I’ll probably go with ngrx, after all :smile: