Skip to content

Load initial data #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
michaelhunziker opened this issue Jun 28, 2013 · 2 comments
Closed

Load initial data #210

michaelhunziker opened this issue Jun 28, 2013 · 2 comments

Comments

@michaelhunziker
Copy link

Hi all!

This may be a duplicate to isue #73 OR I'm really getting something wrong ;-)

I'm having trouble resolving the following issue:

My application looks like this:

  • Parent State
    • Sub State 1
    • Sub State 2

At application startup, I initially need to make an http request to get the role of the current user. The role is then added as a query parameter to all sub sequent http requests. I had the feeling that I needed to do such an initial call within the resolve-part of the Parent State. Is this even the right place for such initial data requests? I can't load the data in module.run() since the states won't wait for async data loaded there. I really need all the states to wait, until the initial data has been loaded. Doing this within the resolve-part of the Parent State does obviously not work since ui-router resolves all states in parallel (as stated by Karsten in issue #73 ), thus the sub-states would crash because the role has not been loaded.

Has anyone a better idea where to load such initial data before the states are loaded?

Thanks for your help!

Cheers Michael

@ksperling
Copy link
Contributor

Once #73 is fixed this should work as you intend it to. Resolves will happen in parallel as much as possible, but will still respect explicit dependencies between the functions.

@michaelhunziker
Copy link
Author

Thanks Karsten.

I'm really looking forward to this feature ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants