Skip to content

Controller is reloaded on $state.go despite notify set to false. #3533

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

Closed
dockinkong opened this issue Sep 20, 2017 · 12 comments
Closed

Controller is reloaded on $state.go despite notify set to false. #3533

dockinkong opened this issue Sep 20, 2017 · 12 comments

Comments

@dockinkong
Copy link

dockinkong commented Sep 20, 2017

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.

@danidev
Copy link

danidev commented Sep 21, 2017

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?

@nkoterba
Copy link

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.

@Sharondio
Copy link

Never good when you find yourself on a fresh issue thread after fighting with something for the better part of 2 days.

@Sharondio
Copy link

For those still following along, checkout the comments about the usage of notify: #1758

@shaggeh
Copy link

shaggeh commented Oct 20, 2017

Is there a workaround we can follow?

@intergalacticspacehighway

$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.

@guillaumevincent
Copy link

@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' });

@maximilianschmid
Copy link

relates to #3650

@maximilianschmid
Copy link

think dynamic parameters is what replaced notify:false option

@christopherthielen
Copy link
Contributor

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

@christopherthielen
Copy link
Contributor

@dockinkong
Copy link
Author

With so much delay, thanks...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants