Jul 15, 2020

Creating an angular service to share data between components using session storage

Create the session storage service as:


To store and retrieve the session storage data, use the service as:


Creating an angular service to share data between components

Create a Data store to save data as key and values. E.g:


Note: It uses build in Map data structure and it already has function to add, remove, delete and check objects.

Now let's create a service.


To store and save data call the service as: