Skip to content

Load initial data #210

Closed
Closed
@michaelhunziker

Description

@michaelhunziker

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions