how to get url parameters and route angular code example

Example 1: angular routing url params

const appRoutes: Routes = [
  { path: 'crisis-center/:param1', component: CrisisListComponent },
  { path: 'hero/:param2',      component: HeroDetailComponent },
];

@NgModule({
  imports: [
    RouterModule.forRoot(
      appRoutes,
      { enableTracing: true } // <-- debugging purposes only
    )
    // other imports here
  ],
  ...
})
export class AppModule { }

Example 2: angular url parameter

// example url: details?id=2

constructor(private activatedRoute: ActivatedRoute) {
  this.activatedRoute.queryParams.subscribe(params => {
        console.log(params); // Prints {id: "2"}
    });
}