angular 6 get route params code example
Example 1: angular get url params
import { ActivatedRoute } from "@angular/router";
private $route: ActivatedRoute
this.$route.params.forEach(param =>
this.myvar = param['whatever your param name is']
);
Example 2: 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 }
)
],
...
})
export class AppModule { }