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
915 stars 211 forks source link

Can deepRedirect conditionally redirect? #126

Closed stites closed 9 years ago

stites commented 9 years ago

I've been looking for a solution to conditionally route my states which, I believe, deepRedirect is the closest feature I've come to finding a solution for it. I wanted to get someone's opinion on this before I started building a plugin for angular-ui-router. It's the same issue as listed in these stack overflow questions.

Situation: I have an abstract "report" state which holds several sub-states of "types of report" — the state itself is nested because we use it in two locations on the site. The report state resolves an ajax request which indicates the report type, then it should use this information to inform the abstract state which sub-state to render.

Problem: I've hacked at this a few different ways (and for a few days now) and the primary issue is that if one were to navigate on page load, the state transitions from "" to "main.report.type1". Now, I ask this question here because I thought deepRedirect could split out the transitioning states and I would get to see the transitions from main->report->type1, which I think I can work with to find a fix, but this isn't the case.

I'm wondering if I simply don't understand the tools well enough, or if this is not something encapsulated in these extras. Also I'm thinking that this feature of conditionally redirected states seems to wind up as a useful feature every now and then, so — if it's not possible — would you guys consider this as a pull request for ui-router-extras?

Happy New Year! Also, apologies for the mouthful.

Thanks, -s

stites commented 9 years ago

Going to close this. I found a fix for my problem which is, in essence, the same as issue 42 on ui-router. I think it's a bit of a hack to listen on an event for all states and only redirect a subset of them — on a deadline though! Thanks for space!