I want to pass a value with url using routerLink. And read that value on another page. Like I have product list. On select of first record the id of that record pass to product
Try this:
Step-1: In routing module
{ path: 'product/:id', component: ProductDetailComponent }
Step-2: Send the value to routing
Home //say, id=5
Step-3: Read the value in ProductDetailComponent
First inject ActivatedRoute
from '@angular/router
and say route
is the injected service. Use the below code inside ngOnInit()
method to read it.
id = this.route.snapshot.paramMap.get('id');