1

I want to add query parameters to URL.

http://example.com/#/xyz?queryParams1=data&queryParams2=data

But don't want to navigate from one page to another. I go through angular docs but not able to get how to use it without using @angular/router . The idea behind it is just to track things via URL and not to navigate.

Any help would be appreciated.

2
  • You can read it with plain javascript, but why would you do that if all the reading and parsing logic is there for you in the @angular/router package Commented Aug 8, 2017 at 6:42
  • You want to read it using Angular way, but refuse to use Angular module designed for that particular purpose. Why? Commented Aug 8, 2017 at 7:02

1 Answer 1

2

You could use the Location from @angular/common

This will allow you do update the URL without navigating, for example:

let queryString = 'queryParams1=data&queryParams2=data';
this.location.replaceState('/xyz', queryString);
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.