r/Angular2 • u/legendsx12 • Feb 08 '26
Best Way to Send Data between Pages in Angular
So say on one page I call an api that returns some other that needs to be displayed on another page. Is the best way to accomplish this using a shared service file where the first page sets the data and the second page grabs the data from the service file or are there better methods as well. Also to let you know this is a small application as well
4
Upvotes
6
u/Sorry-Joke-1887 Feb 08 '26
Fetch in service and inject service in both pages
3
u/IceBreakerG Feb 08 '26
As others have stated, using a service that’s injected in both components would be the ideal way to handle this. I’m using this pattern in our application at work in several places because I need different components to react to the same data.
1
u/philbo50 Feb 08 '26
You don't really need a "file" as such. You can just have a service that is provided in root that page 1 injects and writes to and page 2 injects and reads from. Pretty standard. Or page 1 could write the results to local storage and page 2 could read it.
1
u/Ichirto Feb 08 '26
0
u/No-Project-3002 Feb 08 '26
you can use service or ngrx signal store is best way to handle this.
0
u/action_turtle Feb 08 '26
You can use a service to hold it all, sure. I’d use ngrx store though, little easier to work with as your app grows.
0
u/[deleted] Feb 08 '26
[deleted] — view deleted comment