0

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.

3 Answers 3

2

try this:

path: { ':parameter/test/list' }
[routerLink]="[paramValue + 'test/list']"

or

path: { 'test/:parameter/list' }
[routerLink]="['test/' + paramValue + '/list']"
Sign up to request clarification or add additional context in comments.

Comments

1

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.

2 Comments

Thanks Martin. When I do this the '/' in the URL 'test/list' gets replaced with '%2F' which is the encoding reference for the slash character. Like - 'paramValue/test%2Flist
Well maybe you need to change route link: [routerLink]="[paramValeu, 'test', 'list']. Because route link use the route segments separate.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.