1. Here is the code for First Component and that I have added into my app.firstcomponent.ts file:

Here I am setting data

...
import { Router } from '@angular/router';
...
export class FirstComponent implements OnInit {
 ...
adduserdata = "First Component";
constructor(private router: Router) { }
//Button click function or you can try it with api callig also
buttonclick()
{
 // Set QueryParameter
 this.router.navigate(['secondcomponenturl'], {queryParams: {data : this.adduserdata}});
}
...
}

2. Here is the code for Second Component and that I have added into my app.secondcomponent.ts file:

Here I am getting the data

...
import { ActivatedRoute, Router, NavigationEnd  } from '@angular/router';
...
export class SecondComponent implements OnInit {
constructor(private route: ActivatedRoute) {}
...
ngOnInit(): void {
   console.log(this.route.snapshot.queryParams.data);
  }
...
}

If you have any kind of query then please let me know.

#angular 8 #angular 9 #angular7

How to get Query Params from redirected URL in Angular 9?
71.60 GEEK