Closed dockinkong closed 6 years ago
I have the same issue but I read that notify:false doesn't work anymore. I didn't find a solution to change the location without reloading the controller. Could somebody explain a new way to change the path of the page without reload the controller?
I've been struggling with this for over 2 days myself. I need to update the URL (as well as the browser history record) without actually re-loading the page/controllers.
I've tried just about every combination possible using both deprecated and "supported" options and methods and have yet to figure out a working solution.
Most of the information I've read says to use 'dynamic' on your state definition params (if that's what's changing or you want to change).
However, I've found that doesn't update the URL or add an entry to browser history.
Never good when you find yourself on a fresh issue thread after fighting with something for the better part of 2 days.
For those still following along, checkout the comments about the usage of notify: https://github.com/angular-ui/ui-router/issues/1758
Is there a workaround we can follow?
$stateRegistry.register({name:state.name, url:'/'+state.stateUrlValue, template:element.content, controller:"stateController", reloadOnSearch:false });
I too had the same problem in spite adding parameters in $state.go, it was still reloading the controller Setting the value reloadOnSearch to false did the trick for me.
@shaggeh
add reloadOnSearch: false
in your routes as a workaround:
.state({
name: "names",
url: "names",
component: "Names",
reloadOnSearch: false,
})
In your controller $state.go("names", { param: 'newparams' });
think dynamic parameters is what replaced notify:false option
People generally used notify: false
to stay on the same state, manually fetch different data, and update the URL (usually changing a parameter value). However, notify: false
was a bad idea because it introduced many edge cases and bugs that simply couldn't be reasoned about or worked around properly.
Dynamic parameters are intended to implement this most common use case, but in a way that isn't a horrible hack. Here is the current docs for dynamic parameter which describes what they do: https://ui-router.github.io/ng1/docs/latest/interfaces/params.paramdeclaration.html#dynamic
here's a simple dynamic parameter example: https://stackblitz.com/edit/ui-router-angularjs-dynamic-parameter?file=app.js
it uses uiOnParamsChanged
: https://ui-router.github.io/ng1/docs/latest/interfaces/ng1.ng1controller.html#uionparamschanged
With so much delay, thanks...
Hello,
My version of UI-Router is: (1.5)
Bug Report
Current Behavior:
Controller is reloaded with $state.go('myApp', { }, { notify: false, reload: false, location: 'replace', inherit: false });
Expected Behavior:
Should the controller not reload with this options? I need to change the URL without reloading controller.