'Angular 8 : What is the best way to store some temp data to transfer between the components

I need to store some temporary data to communicate between the component. (say the data is JSON). We have a lot of ways like LocalStorage, SessionStorage, Service, CustomEvent etc... What is the best way in this scenario?



Solution 1:[1]

If Components are in Parent-Child relationship then you can go with Input-Ouput decorators, If they are sibling then go with services. In some scenario developer uses queryParams (but make sure to encrypt the data).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Prashant Singh