activate router angular code example

Example 1: activate router angular

ngOnInit(): void {
    console.log("activated route", this.activatedRoute);
    this.activatedRoute.paramMap.subscribe(
      (params: any) => {
        console.log("in params", params);

        this.userid = params.get('id');
        console.log("in user id", this.userid);
        this.getProfile();
      }
    )

Example 2: activate router angular

ngOnInit(): void {
    console.log("activated route", this.activatedRoute);
    this.activatedRoute.paramMap.subscribe(
      (params: any) => {
        console.log("in params", params);

        this.userid = params.get('id');
        console.log("in user id", this.userid);
        this.getProfile();
      }
    )

Example 3: activate router angular

ngOnInit(): void {
    console.log("activated route", this.activatedRoute);
    this.activatedRoute.paramMap.subscribe(
      (params: any) => {
        console.log("in params", params);

        this.userid = params.get('id');
        console.log("in user id", this.userid);
        this.getProfile();
      }
    )

Example 4: activate router angular

ngOnInit(): void {
    console.log("activated route", this.activatedRoute);
    this.activatedRoute.paramMap.subscribe(
      (params: any) => {
        console.log("in params", params);

        this.userid = params.get('id');
        console.log("in user id", this.userid);
        this.getProfile();
      }
    )