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

How to Handle Vanity Route with Future States? #321

Closed chrisguerrero closed 8 years ago

chrisguerrero commented 8 years ago

Hi all,

I'm using UI Router future states along with webpack and ocLazyLoad to dynamically download and execute modules. In my future state factory for each module, I register the entire state tree for the module using UI Router's $stateProvider.

My question is about the order in which states are registered. Given the following future states:

The future state loading works correctly if I visit /jobs first, and then navigate to /chris. However, if I visit /chris first, the /{username} state is registered with UI router before /jobs, so when I navigate to /jobs it attempts to load the /{username} route.

Is there any way to make sure /{username} always comes last, even if /jobs is registered after?

Thanks!

christopherthielen commented 8 years ago

I think that's a tricky one. This is a problem core to ui-router itself, which is in turn exposed by future state registration order.

My best idea is to register ONE future state (i.e., /{username}) and then register BOTH states in the proper order with your Future State Factory.