-
Notifications
You must be signed in to change notification settings - Fork 3k
resolve is always called with notify:false #2146
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
Does seem like a bug |
Thinking more about this...
Documentation doesn't mention nothing about controller and resolve feature. thanks |
Looking at the code I have a possible solution, here my fork+commit: https://github.com/davideicardi/ui-router/commit/7198aa2b3618f11b376949a80e2b7c4c6640cd4c Basically I have checked the notify options inside shouldSkipReload function. I have also added a unit test. (don't know why there are also other CRLF changes...). Eventually I have also a different workaround not involving changing any ui-router code: plunker. I have added a custom "resolve" params and use it as an option to check if calling or not the resolve functions. So I can call the $state.go like this:
But I don't like this solution, seems to be just a workaround. What do you think? I'm not sure what is the right approach... |
#2087 has the controller reinitialize when changing to a different state. This has the resolve fired but not the controller so its slightly different. |
Right... that's because it's totally unrelated: |
My final goal is to change the state and browser URL (actually I just need to change a state par) without reloading the controller or calling the resolve. What is the best solution for you? I just don't understand how to solve my problem. |
Why? |
Basically I have backoffice application where the user can add new articles/stories. So I have a state like "/stories/{id}". Thanks |
Plenty of ways to replace the url but the original issue is still valid:
|
Thanks Eddie but what do you suggest for changing url? For me it should be some ui-router feature, something like:
or
In my opinion is a state change just like any other, the only problem is that the user is actually already in this state (all the required data are loaded) so I just don't want to reload anything. |
|
Yeah, see the example with the |
@nateabele Shouldn't the example use Also, it's not helping regarding the url change imo. If I don't use |
@nateabele @eddiemonge I've been working on a project and having a similar issue as that discussed here. This is my use case: When transitioning to a state, a resolve block is completed. Once in the new state, a component determines whether or not the url needs to be changed. The goal is to remain in exactly the same state, but to modify the url. However, when I make the url modification using something like this:
The entire state remains the same and the url is updated. However, the resolve block is the called again. Is it not possible to prevent the resolve block from running? |
I want to change the state without reloading the controller. All seems to work fine except that my
resolve
function is always called.To change state I use:
Here my plnkr: http://plnkr.co/edit/jo3C56ZwkPE27FtRU1Y6
Basically I log each time the controller is loaded or the resolve is called, then I added a button to change the state. As you can see resolve is always called also with notify = false.
What do you think? My problem is that inside the resolve I load some resource and I want this code to be called only when really changing state, not when changing state using
notify=false
.I use version ui-router 0.2.15 and angular 1.4.3.
The text was updated successfully, but these errors were encountered: