Search code examples
angularangular-router

Angular 4 - Adding router param before url


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.


Solution

  • try this:

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

    or

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