1import {Router, ActivatedRoute, Params} from '@angular/router';
2import {OnInit, Component} from '@angular/core';
3
4@Component({...})
5export class MyComponent implements OnInit {
6
7 constructor(private activatedRoute: ActivatedRoute) {}
8
9 ngOnInit() {
10 // Note: Below 'queryParams' can be replaced with 'params' depending on your requirements
11 this.activatedRoute.queryParams.subscribe(params => {
12 const userId = params['userId'];
13 console.log(userId);
14 });
15 }
16
17}