I recently posted a question on SO asking about how to structure a controller for a multipart-view where the most upvotes answer in comments was: Use ui-router.
The goal (as described in the other question) is to create a page which looks like the following:
...with this workflow:
- When the page loads, a list of data1 is being fetched from api1 which then gets populated in the table at the top.
- When the page loads, a list of data2 is being fetch from api2 and populated in the table to the right.
- When the user clicks on a entry in the table at the top, a detail view of data1 is being populared in the left part and some fields are being highlighted in the right table
I spent the last days learning about ui-router and I'm still unable to figure out how to do this, especially due to lack of samples about ui-router.
What I got in mind:
- One abstract State (root state) for the layout with a uriTemplate
- 3 views, (root.tableTop, root.detail, root.tableRight) with each a template and a controller (tableTop fetches api1, tableRight api2 and so on).
- Directives for highlighting
But: How do they communicate with each other? How can I propagate that the user has clicked on a row on tableTop and now detail needs to update? Through $rootScope? Or should I forget about views and work with nested states?