Communication between pages in nav controller

Hi -
I have push one page in nav controller.

How can I send query from child page to parent page without dismissing the child page.

You can use nav params.
It send using nav push. and get nav params.

-nav push

-nav params.
http://ionicframework.com/docs/v2/api/components/nav/NavParams/

regards.

Hi - Thanks for the reply

nav push params will send the params from current page to the child page.

I need to send query from child page back to current one without dismissing the child page.

Like in page1.ts -> this.nav.push (page2);

Now how can I send query or access any function of page 1 from page 2

Sorry. I mistake.

probably (sorry, I weak English…), You can use @ngrx/store. this can share variable.

Or webstrage, SqlStorage, You can.

can you please elaborate your need with some code

I have an array of objects say items and for any selected item I need to show some pop up. Now from within the popup I want to provide an option to load next/previous item from the array of items

var items: Array

this.nav.push(page2, {item: item});

So once the page 2 is loaded - I need to find the index of current item in array of items from parent page and load the next/ previous item.

Thanks.

What I would do is to move the storage of the list of items out of the page and into a service. That way any component that needs it can simply inject that service.

agree with using services for this case

Or you could use Ionics Event system:
subscribe for the event in your parent page and publish the event in your child page.

1 Like

i’m facing the same problem, and the suggestion from @sZerner was a good idea.
it solved my problem.