christopherthielen / ui-router-extras

THIS PROJECT IS NO LONGER MAINTAINED -- Extras for UI-Router for AngularJS. Sticky States (a.k.a. parallel states), Deep State Redirect (for tab-like navigation), Future States (async state definition)
http://christopherthielen.github.io/ui-router-extras/
MIT License
917 stars 211 forks source link

FutureStates question: Using parameters with future states #329

Closed stevie-p closed 8 years ago

stevie-p commented 8 years ago

I have a use case to dynamically (at run time) load a new state tree, triggered by user navigation from either inside (e.g. via ui-sref) or outside (via url) the app.

So I think the FutureStates module of ui-router-extras should be the way to go.

But the states I need to load dynamically are based on a state parameter, i.e. an ID. For instance:

NewState {
  ID: 1
  Name: MyBrandNewState
  Substates: { 
    Substate 1 for NewState 1
    Substate 2 for NewState 1
    Substate 3 for NewState 1
  }
}

The Substates will be different depending on the ID.

So, while I can dynamically create a newState state, how can I pass a $stateParam (or similar) to the StateFactory function so that it can dynamically load the correct substates?

Does ui-router-extras not cover this use case?

Maximaximum commented 8 years ago

I'm looking for an answer to this question, too. In fact, the Future States features seems pretty useless to me if there is no way to dynamically get the url parameters and, depending on them, create the state structure needed.

Are we missing something?

christopherthielen commented 8 years ago

Does ui-router-extras not cover this use case?

Future states does not support this use case, sorry.

Maximaximum commented 8 years ago

Actually I've found out that you can simply get the url params like this:

var params = futureState.urlMatcher.exec($location.$$url);

christopherthielen commented 8 years ago

That probably won't work with $state.go like a ui-sref