Reputation: 149
How can I pass the data of home(page 1) to ContactPage(page 3) along with DetailsPage(page 2) data?
lets say
HomePage has data of "UserId"
DetailsPage has data of "UserName" & "UserAddress" //this page doesnt have UserID
now how can i get the data of "UserId" as well as "UserName & UserAddress" on ContactPage?
Upvotes: 1
Views: 86
Reputation: 698
in HomePage pass data as follow
this.navCtrl.push(DetailsPage, {
UserId: 'UserId'
});
in about page
--retrieve value using
this.UserId = navParams.get('UserId');
--and send data from DetailsPage to ContactPage as
this.navController.push(ContactPage, {
UserId: this.UserId, UserName: 'UserName', UserAddress: 'UserAddress'
});
Upvotes: 1
Reputation: 241
Refer following link to pass data from one page to another page
Passing-data-between-pages-in-an-ionic-application
Upvotes: 0
Reputation: 1401
You can follow several ways
From your home page store userId in localStorage
localStorage.setItem('userId',<your variable>)
then from your second page if it is not a root page
this.navCtrl.push('ContactPage',{
userName:<your variable>,
userAddress:<your variable>
})
then from your third page
fetch userId from localStorage
like localStorage.getItem('userId')
and the userName and userAddress using NavParams
this.navParams.get('userName'),
this.navParams.get('userAddress '),
let me know your outcome
Upvotes: 0