-
Notifications
You must be signed in to change notification settings - Fork 3k
Conditionally block routing #1714
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
I'm having the same issue with this, I haven't figured out why this isn't working. |
It's difficult to tell without seeing more of your app, but this may be related to #1699. It appears that |
I was just reading some more on this, and I found out my |
That appears to be correct, yes. You'd have to move that logic to a state - possibly the "otherwise" state, which is the fall-through, rather than as part of your app startup cycle. |
Could I, in theory, move all my $state.go into a service, call the service in the run and just live happy? Or would that cause issues, or bad practice? I'm trying to figure out a good solution that doesn't involve heavy logic in the controller. Sent from my iPhone
|
You could put all that logic in a service and then call that service from the controller. That's a fairly typical pattern anyway. I'm guessing here, but I would suspect that you can't call it from |
Hmmm. Fair enough, I think this answers my question and I'll give it a shot. As for @spidergears I'm not sure if this helps.. |
DOUBLE EDIT:
EDIT: Jk, having this issue. It still isn't redirecting. Here is the only login I have in the service.
And I just call it in the controller like |
@mikehuebner @michaelcox I went through a few more issue and looks like its something how angular has been implemented. What seemed to do the trick for me was using native window.location for accountSetup redirect. The other two redirects for campaign.index and segment.index still work good with $state.go() . i am still looking into it as why the other two redirects work but not this. Only thing different is that the other two redirects are only called on user login and no time later. |
@mikehuebner - I think you've probably gone past the scope of an issue against this project. I'm not sure what's up, but you're probably better off either asking on StackOverflow or trimming your project down to a simple Plunker if you think there's an actual bug with UI-Router. |
I am trying to block routing in my application conditionally, as in code below. In all scenarios the code works fine except when the user opens a new tab and tries to access an inaccessible url, the digest cycle seems to go into a loop, since the state keeps switching between
setupAccount
and campaign.index, in case the user is trying to access /campigns url when he has not configured currency and timezoneThe text was updated successfully, but these errors were encountered: