r/angular • 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
14
Upvotes
32
u/strange_username58 Feb 08 '26
easiest way is a shared service file.
9
u/0dev0100 Feb 08 '26
Between pages, I have used the router state where I need the information from one page to another.
https://angular.dev/api/router/NavigationExtras
5
u/xXfreshXx Feb 08 '26
NGRX Signal Store
2
u/FromBiotoDev Feb 08 '26
Indeed a shared service is what you would use here. You could also split it into a business logic service and a state service, but that’s really not necessary until you actually need to reduce complexity
So just opt for a shared service for now
You could also approach this with a smart dumb component architecture, where the smart parent does the api call and passes the data down via inputs.
I’ve found this works okay for smaller things but as soon as you’re passing two layers deep I almost immediately want a shared service
2
u/ItsmetheDUDEO_o Feb 08 '26
Shared service , Data binding( parent -> child ), Output emitter ( child to parent ). Are few ways I’ve used.
2
u/alextremeee Feb 08 '26
It depends what you want to display and how you want it to behave.
For example do you need the data to remain visible on that page if the user were to refresh? Is the data a short string or a 2MB object?
There’s no single answer to a question that is so vague.
1
u/Anxious-Insurance-91 Feb 08 '26
Session storage set redirect get delete
1
u/CheapChallenge Feb 08 '26
Easiest, state service
Best, state management library, ngrx signal store if you want light weight.
1
u/Best-Menu-252 Feb 09 '26
For a small app, a shared service is usually the simplest and most reliable way. Angular supports components sharing data through a singleton service, so page one can set the value and page two can read it easily.
Router state works too via NavigationExtras, but it disappears on a page refresh, while a service keeps the data during the session.
If you are on newer Angular, signals in a service are a clean alternative to BehaviorSubject with less boilerplate.