1

When a user logins the ionic app, how do I pass the user ID to the pages listed in side menu.. Is there a possibility to send data through navParams?

Karthika
  • 45
  • 1
  • 8
  • you can maintain the localstorage variable and based on that localStorage variable you can change the page or page link in your app component. – Taylor Rahul May 01 '18 at 10:14
  • And Yeah NavParams and NavController has this feature you can send data while you push the page. and read those data through navParams – Taylor Rahul May 01 '18 at 10:17

1 Answers1

2

You have to store user ID in ionic storage when the user is login like this,

First, add Ionic storage in your app,

Then, use ionic storage in login component like this,

// set user ID
storage.set('userID', 'Your_user_ID');

Now, get the user ID in whichever component you want like this,

// get user ID
storage.get('userID').then((val) => {
  console.log('user ID', val);
});

Thank you.

AddWeb Solution Pvt Ltd
  • 21,025
  • 5
  • 26
  • 57