-
Notifications
You must be signed in to change notification settings - Fork 3k
Using optional parameters reloads controller when moving away from state #1673
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 believe I'm experiencing the same (or a related) issue. I'm using Angular 1.3.8. I don't think this occurs in 1.2.*. In my case, if I navigate to the same state with different params and notify false then navigate to another state, the first state's controller is initialized again between the start and success of the state change. Here's a plunker replicating this problem: http://plnkr.co/eOtj7C6mMgK8qwVqBEXi Console log:
Problematic part:
The home state controller is initialized while the state is being changed. |
I believe line 1047 of state.js is causing this to occur.
|
I currently have a workaround that involves writing my own ui-sref replacement that retries state transitions until they pass. I send an event in that case and listen to it on controller init to make sure the controller can safely reload. A resolution to this issue would be critical. This effectively breaks optional parameters and requires a lot of hacks. EDIT: I am running Angular 1.3.0 |
+1 I'm currently experiencing the same issue as @jessezhang91. When I update my search params by calling $state.go to the current state with options I'm using angular 1.2.28 and ui-router 0.2.13 |
@chrisguerrero I have the same problem. Even if inherit is |
I have not found a workaround. Rather, I just let the controller run again but make sure it doesn't do anything to change states. I initially thought setting |
@SebastianM My issue stemmed from the fact that I was using UI router in a non single page app. I was trying to pass parameter values across page requests, which is why I needed to reload the state. I've since moved to a true SPA and can now pass those parameters on state change using $state.go |
I'm seeing this same issue in an SPA. I update params by using |
Any movement on this? |
Probably not. I've completely abandoned Angular and this framework was a large part of that decision |
This is exactly the problem I have - I'm updating the url with optional parameters in response to user selections with notify:false state changes, and then when I try to navigate to a different state, it re-initialises the current state too. |
It seems this is still an issue with ui-router 0.2.14 and angular 1.3.13. I noticed that the hash does not change when this issue occurs. I wrote a workaround that decorates the $state.transitionTo function to detect when it does a "notify: true" transition after having done a "notify: false" transition. After that transition has successfully occurred, I save the "fromState" from the "$stateChangeSuccess" event and the hash from window hashchange. The next call to $state.transitionTo that has the same hash and same state within 500ms will be ignored. Craziest workaround but it seems to work for my case. This is definitely not a fix but, looking through the source code, there's no obvious way to make it work properly.
|
This is quite bad, how come it has not been properly fixed in 5 months? |
I dug into the code a bit and found that the issue occurs because The first transition with Afterwards, Luckily, it seems that PR #2003 fixes this interaction. It seems to fix the issue in my project and it passes my plunker: http://plnkr.co/edit/UoC6rk2zKQItQNji0OPr
|
+10 |
+1 |
@btm1 you only get one vote. |
Hi guys, any luck with this one? +1 |
+1 |
This should be fixed by #2003 which was just merged this morning. |
Fixed in f9b43d6 |
@christopherthielen |
@checat that is likely a side effect of using |
I define a state like this:
With two optional parameters and one required.
I have a function that periodically updates the X and Y optional parameters like so:
The problem is that after I update the optional parameters, and after I trigger any kind of state change (ui-sref or $state.go) the state transition sometimes fails.
I'm also listening on every UI Router even on the $rootScope, but this failure is never reported to those events. Clicking on a ui-sref link simply reloads the current controller.
Any ideas why this may happen?
The text was updated successfully, but these errors were encountered: