question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: Is it possible to change query params without reloading route?

See original GitHub issue

I’ve got a strange use case - I’ve got a checkout form where user can select a product and enter a discount coupon. Now, whenever user changes a selected product, or enters a coupon, I’d like to persist this info in query parameters, so that when user reloads the page, or sends its url to someone else, they will see the page in exactly the same state. However, if I use navigation.navigate (or history.push) to change query params, it triggers route change and executes routing code again and I’d like to avoid that. Angular 1.x router has reloadOnSearch option that could be set to false, to avoid reloading route on query params change. Is it somehow possible to do the same thing with navi?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
jamesknelsoncommented, Jun 27, 2019

I’ve come across a similar problem so I definitely want to find a good solution for this. The issue is that HTTP redirects on the server can’t pass state through, and I want the API to work across both SSR and the client.

I have a few ideas about this, just need to find the time to put them into a proposal or some code.

0reactions
szimekcommented, Jun 22, 2019

One more use case 😉

We support PayPal payments and we need to pass a failure url that PayPal will redirect to in case of, well, failure. In our case the failure url is the same checkout page, where user initiates PayPal payment. We only append a query param with an error message to it and PayPal appends a token query param. In our old Angular app, we checked for these query params on page load, showed an error message and removed them. This way when user would e.g. reload the page, they wouldn’t see the same error message again. Because this logic happened in a component, we could already preselect PayPal as preferred payment when these query params were present.

In navi, it looks like I can redirect to the same url without these query params, but then I won’t know that user had PayPal selected. Unless it’s possible to pass state to redirect function, just like to navigation.navigate? Not a big deal, but would be useful to support this use case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular: How to update queryParams without changing route
The Best Answer is ... You can navigate to the current route with new query params, which will not reload your page, but...
Read more >
change route params without reloading browser in angular
I have face this problem when I kept my apps data in route param and that require to change (when user change apps...
Read more >
Angular 6 add query params without reloading - iTecNote
You get the new query params by subscribing to queryParams changes For example: constructor( private activatedRoute: ActivatedRoute, ) { } this.activatedRoute.
Read more >
Angular: Change the route without reloading - Medium
In order to update the route without a reload of the entire component (page) I had to resort to plain ol' JavaScripts replaceState...
Read more >
Angular Basics: Using Query Params in Angular Routing
Today we will look at how we can pass query parameters to the URL of our app using the routing module in Angular...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found