1

I am trying to fetch queryParams from url with window.location but query params are not being grabbed.

Example my url is www.abc.com?accountId=123# I am looking for a way to grab accountId=123 as a queryParam or atleast the entire url.

When I used window.location I am getting www.abc.com/#/ instead of www.abc.com?accountId=123#

Why am I not able to read the query params?

Why am I not able to read the query params?

1 Answer 1

1

according to the angular documentation you can fetch the query parameters with the activatedRoute in Angular.

In the below example we grab a query parameter "name".

constructor(
  private route: ActivatedRoute,
) {}

ngOnInit() {
  this.route.queryParams.subscribe(params => {
    this.name = params['name'];
  });
}
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.