Return to site

ANGULAR: How can we pass parameter in Routing?

· github

1. On the html page, use like:

<a [routerLink]="['/product',product.id]">{{product.name}}</a>

 

2. After that, in component (.ts) file:
a) Inject ActivatedRoute in constructor like:

constructor(private _Activatedroute: ActivatedRoute){}

 

b) After that, use like:

const _id= this._Activatedroute.snapshot.paramMap.get("id");