How to pass data from Sidemenu to other Page while navigating

my sidemenu control is in app.component.ts and html in app.html…

know i am Navigating from sidemenu to a page… here i need to transfer a data from tab to page but my control is in app.component.ts

Please give me a solution…

Thanks.

it is same as usual. you don’t have to do anything extra.

if you navigate page from side menu like this =>
this.nav.setRoot(yourcomponent);

then you just have to pass value in parameters
this.nav.setRoot(yourcomponent,{param1:value});

and you have to get that param in corresponding component
this.param1 = this.navParams.get("param1");

How about reverse, sending a parameter from page to sidemenu?

if you use nav.pop() then you can’t pass value in parameters
in this case i use localstage to pass parameter :wink:

yes we are doing same now, but not sure if its best option…or do away with side menu altogether and use something else

Storage is a bad choice for in-app communication. It should only be used for things that need to persist across app restarts. For in-app communication, use a mutually injected service provider.

2 Likes

I have the same problem but i cant find any “this.nav.setRoot(yourcomponent);” in my app.compnent.ts or in my home.page.ts.
have anybody a solution?

You may use global variables as per below

@Injectable()
export class GlobalProvider {
public G_PARAMS :string;
}

in your first screen load event, assign the global params
G_PARAMS = {xyzzy:“abc”}

when clicked on menu, it redirects to the desired page, in constructor of that page, read the global params instead of nav params
console.log(GlobalProvider. G_PARAMS);