-
Notifications
You must be signed in to change notification settings - Fork 3k
State specific rules and redirects #665
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
Comments
This can already be accomplished by attaching custom data to states using the |
Thanks @nateabele. I assumed someone had probably already asked this but just couldn't find an issue regarding it. For now I will use the state change event, however I will also contribute to the discussion and provide some code for how I would implement it. |
@josh-hobson if you are feeling crazy, please feel free to add an item on this topic to the FAQ. |
@josh-hobson Yeah, this is still pretty open territory, and I'd be happy to help collaborate on a 3rd-party module if some common patterns emerge. |
I have run into a problem in my app using ui-router where I need state specific rules to determine whether or not a user is allowed to view a certain page in the app.
This is the question I asked on stack overflow: http://stackoverflow.com/questions/20472136/state-specific-rules-and-redirects
Having looked through the source however it looks like this can't be done. I could use urlRouterProvider to create rules however the app has a large state tree and requires data loaded in resolves of previous states to calculate the rules of its children. As far as I'm aware, urlRouter is hit first when a new location is provided so in some cases the required data may not have been loaded yet (for example, navigating directly to the url).
A quick example of the use case would be a questionnaire where you don't want the customer to go to page n+1 without having completed page n. A rule on the page state would allow you to quickly check which page they should be viewing.
I believe this could also be useful in other cases, such as having a rule to provide a default child state for an abstract state if no child was provided.
I am willing to put in the time to try and work out how to do this, I'm new to angular UI but would enjoy the work. However I just thought it would be worth checking that:
a) I haven't missed a feature that would achieve this,
b) Someone isn't already working on this,
c) There aren't any reasons against doing state specific rules, philosophical or otherwise.
The text was updated successfully, but these errors were encountered: