-
Notifications
You must be signed in to change notification settings - Fork 49
When would you getTasks() #12
Comments
One of the awesome parts about ui-router's resolve chaining is you can make them siblings: resolve:
project: (AppObject, $stateParams) ->
AppObject.getProject($stateParams.projectId)
tasks: (project) ->
project.getTasks() Of course this will chain the queries and perhaps slow down the loading of the page. It just occurred to me that if ui-router doesn't load children states async then you can get a performance boost by placing the project's tasks into a substate, but this may not necessarily make sense for your navigation which is why the above solution should work too. |
Amazingly quick response. I didn't know ui-router would chain those resolves, very cool. Substates is more what I had in mind, but I'm not sure how you would load the tasks into a substate of the project by default. The ui-router setup in that case isn't very clear to me so I'll need to dig into the docs a bit more. |
Yeah that SPECIFIC scenario has been sorta tricky for me in the past. Like lets say you get sent to It's similar to the concept of an abstract state, like project essentially IS an abstract state, but if you DO navigate to it, you get pushed into a substate. In fact... angular-ui/ui-router#1235 |
Given you hit the individual project state, which resolves a project to be injected into to the ProjectController.
Say you want to display the tasks for the project immediately for that state. At what point would you call the getTasks()? Would you do this right away in the ProjectController?
Or, would you make it part of the resolve?
Or maybe you were thinking something completely different?
The resolve works quite well with states, but once there aren't states I'm a little unsure on how to fetch the children.
Thanks for any help.
The text was updated successfully, but these errors were encountered: