Newbie Question - how can I share REST payload between routes (call REST service once, rerender many times)?

15 views
Skip to first unread message

StevenB

unread,
Feb 18, 2020, 5:05:43 AM2/18/20
to Angular and AngularJS discussion
What do I search for to learn how to load a REST payload on the first page and share it among multiple routes, ideally with bookmarkable URLs?

I am extremely new to Angular and front-end development in general.  (backend dev prototyping visualization tool I wrote).  

I have a REST service that returns hierarchical data.  Printing it all on the first page is just too difficult to read/format, so I want the user to click on links to see more details in the hierarchy. View 1 shows the summary stats, View 2 shows the components, View 3 shows the detailed results per component.  I wrote a basic JavaScript prototype that loads the data on startup and keeps rewriting the page as the user clicks on links.  It works fine, but I want to port it to Angular.

It's really nice because it takes 2 seconds to load on the first screen (from the actual REST call - very expensive, unavoidable processing), but every click after that is instantaneous. 

I wired up my application to render view 1.  I just haven't figured out how to pass the data from step 1 to step 2.  Ideally, I would love something like the routes function where I could get that same speed, but have a bookmarkable URL for each click the user made.

What can I search for to learn how to do this in angular?  I saw lots of examples, of how to call a REST call from each component and route, but nothing for passing JSON between routes. 
Reply all
Reply to author
Forward
0 new messages