Felipe XST
Felipe XST

Reputation: 151

pass data to sidemenu Ionic

I have a login with fb, and upon confirming, redirects to the main page, however I would like to pass the data to the App.html, because my sideMenu is in it. But I can not find way to pass data to app.component.ts Can anyone give me an idea of ​​how I get data for the side menu?

Upvotes: 0

Views: 1090

Answers (1)

nyx97
nyx97

Reputation: 211

Use the events plugin by ionic

in your app.component.ts file either create a function or put the code below inside the platform ready to listen for any published events

  events.subscribe('user:created', (user, time) => {
    // user and time are the same arguments passed in `events.publish(user, time)`
    console.log('Welcome', user, 'at', time);
  });

in your login.ts file after successfully login publish data using the code below

this.events.publish('user:created', user, Date.now());

for more info please read the events plugin

Upvotes: 1

Related Questions