1

I have a string of query parameter values ie:

var querys = "agentId=5&page=2&name=andrew"

Is there an easier way to use this exact string to get to that page using this.router.navigate otherwise I'll have to manually list it all out like this:

this.router.navigate(['/admin/list'], { queryParams: { agentId: 5, page: 2, name: andrew } });

And of course that gets messy if I don't always know what the query param keys names are going to be.

1 Answer 1

4

you can use below code

this.router.navigateByUrl(`/admin/list?${querys}`);
Sign up to request clarification or add additional context in comments.

2 Comments

I never knew this existed. Thanks so much that worked great :)
@AndrewJuniorHoward any time. If it solves your issue please mark it as answer, so other devs having same issue easily can find the answer then

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.