I'm assuming you have some code like this:
{ path: 'product/:id', component: ProductDetailComponent }
in ProductList template
<a [routerLink]="['/product', id]">Home</a>
or
<a [routerLink]="['/product', 5]">Home</a>
where id is a variable, maybe you got it in a loop.
in ProductDetailComponent:
constructor(
private route: ActivatedRoute,
private router: Router
) {}
ngOnInit() {
this.route.params
// (+) converts string 'id' to a number
.switchMap((params: Params) => this.yourProductService.getProductById(+params['id']))
.subscribe((product) => this.product = product);
}
Router document: https://angular.io/docs/ts/latest/guide/router.html