Skip to content
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

0.2.15 breaks the History API with query parameters #1966

Closed
ghost opened this issue May 19, 2015 · 4 comments
Closed

0.2.15 breaks the History API with query parameters #1966

ghost opened this issue May 19, 2015 · 4 comments
Milestone

Comments

@ghost
Copy link

ghost commented May 19, 2015

The recent fix for #1079, while it did fix the problem of not reloading the state when reloadOnSearch: false, did however break the History API's ability to navigate using the back and forward buttons on the browser.

Before, if I added all query parameters to the state's url, the back and forward buttons would invoke the controller so that I could run the same code as if I manually changed the state. However, even in your plunker example http://plnkr.co/edit/5OPoKUDnn98JiKFlyEYL?p=preview, if I hit the back and forward buttons the controller is no longer called even though the query parameters are changing. I guess technically this is the defined behavior, but developers have no control over the browsers back and forward buttons to run code off those changes.

You can see the work arounds I had to implement in 0.2.13 to be able to change query parameters without reloading the state while still having back and forward ability on this stack overflow answer: http://stackoverflow.com/a/29262392/2124254

@eddiemonge eddiemonge added the bug label May 19, 2015
@eddiemonge eddiemonge added this to the 0.2.16 milestone May 19, 2015
@christopherthielen
Copy link
Contributor

I guess technically this is the defined behavior

Agreed.

If the state isn't reloading, then the controller fn should not be invoked. States with reloadOnSearch are probably be fetching data without a resolve or transition, yes? Try adding a $watch for $stateParams inside a reloadOnSearch=false controller to update your search fetches, based on some query parameters.

Until we get dynamic params implemented, there won't be a clean solution that works for every situation. 👎

$scope.$watch('$stateParams.dynamicparam', function(newval) {
  // fetch updated search
});

Let me know if this addresses your use case

@sandev
Copy link

sandev commented Oct 26, 2015

Any update on this issue?

@evanjmg
Copy link

evanjmg commented Nov 6, 2015

I'm struggling with the workaround as I've never used $location.search(). Anyone have any good examples of a search with a submit and redirect to another page? Is there anything that works with ui-sref links?

@christopherthielen christopherthielen modified the milestones: 0.2.16, after 0.2.17 Jan 25, 2016
@christopherthielen christopherthielen modified the milestones: future, 0.2.18 Feb 7, 2016
@stale
Copy link

stale bot commented Jun 11, 2021

This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues
may be reopened.

Thank you for your contributions.

@stale stale bot added the stale label Jun 11, 2021
@stale stale bot closed this as completed Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants