How to send data to a page without pushing to that page?

Actually i am new to the ionic, i need help: I want to send the data from one page to other without pushing to that page in ionic 3. e.g add to favorite.

1 Like

Maybe you can use IonicStorage

https://ionicframework.com/docs/storage/

use a provider.

see this link https://www.joshmorony.com/when-to-use-providersservicesinjectables-in-ionic/

1 Like

Dear Tanzeel064,

You should declare global variable in service and pass the value to variable from any pages/services so that it is available in entire project. Else go through the Events you can get solution as of my experience. Thanks

In Ionic 3 you can use localStorage to perform this operation
Example:
Page 1

let page1Data='This is Page 1 Data';
localStorage.setItem('storedData': page1Data);

Page 2
Use this Data in page 2 using

let page1Data= localStorage.getItem('storedData');
console.log(page1Data);

For More Details: https://answerdone.blogspot.com/2018/03/how-to-store-and-use-data-globally-in.html

Well I would agree with ralphskie - use a provider that is shared across both pages. Persistence of that data is a separate question I think (you can persist it using Ionic Storage if you need to inside of provider.

thanks your solution sounds well:grinning: