You're going to have to inject ActivatedRoute
into your component. Your routes would have to be set like this:
{ path: 'person/:id/:office_id', component: PersonComponent },
Then subscribe to the params:
constructor(private route: ActivatedRoute) {}
ngOnInit() {
this.route.params
.subscribe(params => {
const id = +params['id'];
const office = +params['office_id'];
console.log(`Current params are person ID ${id} and office ID ${office}`);
});
}
Your routerLink would be:
[routerLink]="['/persons', 2, 5]"
Here, I have injected an instance of ActivatedRoute
as route
in my constructor.
You would need to obtain each of you params that you have listed on your routing for your Dashboard component. In this example, my routing is simple persons/:id
where I would get the id
from http://localhost:3000/persons/1
. So if I had a router link to next person say [routerLink]="['/persons', 2]"
, this snippet of code would update and provide me an id
of 2
.
Based on your current illustration and question, this sounds like the solution your looking for.
StackBlitz Solution
https://stackblitz.com/edit/routing-params