get query params route angular code example

Example 1: angular http request query params

request(query) {
  let params = new HttpParams().set("keyword", query);
  return this.http.get(`Your_URL`, {params});
}

Example 2: in angular how to get router url without query params

this.router.url.split('?')[0]

Example 3: get route query params angular

export class HeroComponent implements OnInit {
  constructor(private _activatedRoute: ActivatedRoute, private _router:Router) {
    _router.routerState.queryParams.subscribe(
      params => console.log('queryParams', params['st']));