before routing activated how can we get querystring angular code example

Example 1: get url params angular

import { ActivatedRoute, Params } from '@angular/router';

@Component(...)
export class MyComponent implements OnInit {
   constructor (private activatedRoute: ActivatedRoute){}
   
   ngOnInit() {
    this.activatedRoute.params.subscribe((params: Params) => {
      if (params.myParam){
        // Do something
      }
    });
   }
}

Example 2: 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']));