Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to persist service data after reload in angular 5

I have a service to pass data between components and when called it works but when i reload the service data gets reset.So when i searched on reload the memory is reset so is there a way to persist data even after reload without using any client side storage ? One thing i am curious is that can i achieve this using rxjs but i am not sure how this would help ?I fear to use localstorage because the data will be mostly objects or array and not user id or session id.Any inputs on this would be really helpful.I have produced a sample example to help me with.You can find below

https://stackblitz.com/edit/component-data-sharing-service

like image 666
Melvin Avatar asked Jan 27 '18 06:01

Melvin


1 Answers

You should be using localstorage/sessionstorage or shared service among components.

You can store the information(object/arrays) using JSON.stringify. If you are using shared service which becomes singleton so you can access across any components.

like image 196
Sajeetharan Avatar answered Oct 13 '22 00:10

Sajeetharan