1

I wanted to work with query string parameters along with the usual route parameters in an AngularJS application and have been following the solution in this post: how to pass querystring in angular routes?

The solution seems to work: Change the route first with $location.path and then apply the query string parameters with $location.search.

However, I came across a scenario where the route does not need to change but the query parameters need to.

For example:

Moving from
'/Books/Programming?id=123'
to
'/Books/Mathematics?id=234'
works fine.

However,

Moving from
'Books/Programming?id=123'
to
'Books/Programming?id=124'
does not work.

It seems that AngularJS is only notified for changes on the regular route parameters and not for changes in the query string parameters so if query string is the only thing that changes in the URL, the application does not respond to the navigation.

Sangwin Gawande
  • 7,658
  • 8
  • 48
  • 66
myTerminal
  • 1,596
  • 1
  • 14
  • 31
  • Works fine here: http://plnkr.co/edit/lefewLl9jvfC2euDxR6X?p=preview. Post a complete minimal example reproducing the problem, as I just did (but without being able to reproduce it). – JB Nizet Sep 11 '17 at 20:53
  • This would sound strange: I was constantly changing the code and after reading your commend, when I brought it back to the state where it only worked with changing query string parameters, it worked perfectly and I could not reproduce the issue anymore. Thanks. – myTerminal Sep 11 '17 at 21:17

1 Answers1

1

As verified with AngularJS 1.6.5, and according to the Plunkr by @JB-Nizet, the problem does not occur anymore. The question still remains for what I missed earlier that it did not work.

Marking it as resolved as it does not occur anymore.

myTerminal
  • 1,596
  • 1
  • 14
  • 31