I have a button in a page like this:
<button [routerLink]="['../edit', 14]">Test</button>
So, if I'm at http://localhost/dashboard
and click the button, I'm redirected to http://localhost/dashboard/edit/14
, which is exactly what I expected.
Now I need to do the same in Typescript. I injected the Router
service in my class and tried the following:
this.router.navigate([`../edit/${item.id}`]);
this.router.navigate([`/edit/${item.id}`]);
this.router.navigate([`edit/${item.id}`]);
But none is working, all of them redirect me to my starting page with no errors.
Does the Router
need some extra setup?