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
Use routerLink
on your a
tag for passing it by url.
[routerLink]="['yourRouteHere', {'paramKey': paramValue}]
To get it you need to use ActivatedRoute
service. Inject it into your component and use it's subscribe method. Here my route
is the injected service
this.route.params.subscribe(params => {
const id = Number.parseInt(params['paramKey']);
}
If you want to get parameters from the route segment use .params
, else if you want from query string, use .queryParams