0

How can I push query params (page, limit) to url in angular, preferably without navigation.

I'm using the new, vladivostok router (npm @angular/router@3) and I have a table with paging. So when I click "next page" or change the number of items per page, I want to have that in the url.

I know I can programatically router.navigateByUrl('/users?page=3') or similar, but can I avoid navigating at all and just update the url? My services will reload the table and everything as needed. Or is that not the way to go?

3
  • What is happening when the current page is /users?page=3 and you navigate to /users?page=4? Commented Jun 20, 2016 at 13:14
  • @GünterZöchbauer it should update. I'll try the window.history answer. Commented Jun 21, 2016 at 14:54
  • AFAIK this is the default behavior. Commented Jun 21, 2016 at 14:55

1 Answer 1

1

I think using window.history would do the trick:

window.history.pushState(null, "pagetitle", "users?page=4");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.