How to Get Query Parameters from URL route in Angular

How to get query parameters from an Angular URL route
 

  • import ActivatedRoute from ‘@angular/router’.
  • Inject ActivatedRoute class in constructor.
  • Access the queryParams property of the ActivatedRoute class. This property returns an observable of the query parameters that are available in the current URL route.

We'll look at an example to help 

Check out the following link.

http://localhost:4200/posts?website=codeehut.com

Now, you can get to the URL parameters in the component by subscribing to ActivatedRoute. queryParams observable