Reputation: 4022
Just wondering whether there is a way to create a angular route with parameter before of in-between a url,
{path: ':param/test/list'} or {path: 'web/:param/list'}
and reference it in routerLink directive,
[routerLink]="['test/list', paramValue]"
Thee parameter value is always getting appended to the end of the url.
Upvotes: 0
Views: 1408
Reputation: 9974
You should put parameter segment in same position to route. Something similar:
path: { ':parameter/test/list' }
[routerLink]="[paramValeu, 'test', 'list']"
Edit:
Separate segments in Route link.
Upvotes: 1
Reputation: 1117
try this:
path: { ':parameter/test/list' }
[routerLink]="[paramValue + 'test/list']"
or
path: { 'test/:parameter/list' }
[routerLink]="['test/' + paramValue + '/list']"
Upvotes: 2
Reputation: 1299
I think this could help :) How to pass a parameter to routerLink that is somewhere inside the URL?
Always better to use router instead of [href]
Good luck
Upvotes: 0