Reputation: 1683
I have 2 Components, they are not child-parent components, just to independent components. I would like to pass data from Component1 to Component2. Is it possible? How could I implement this? Could you please give me an example or maybe a link to an article? I found a lot of articles, but they are all about parent-child components.
Upvotes: 3
Views: 734
Reputation: 19632
You have two options here to pass data between components if they donot have a parent child relationship
Now when to use when if you application size is medium to small go for shared services using behaviour subject or replay subjects. please check this link to know more about behaviour subject and how to use shared services to communicate between components.
Using Ngrx is like a complete long term solution to this problem. It follows the redux pattern to solve state management in Angular. follow this link for more on ngrx and how to use them in a project .
More on ngrx
This is a live project using the whole ngrx suite state management footballapp
Upvotes: 1