Search code examples
angularangular2-router3

Is multiple required parameters support in Angular2 router


Like:

/profiles/:category/:profileSlug/:page

Because I cannot generate URL with [routerLink]="['/profiles', {category: 'president', profileSlug: 'obama', page: 1}]" returns unexpected result in matrix query format

So in Router3 I must hard the whole URL by myself? If true then Angular's router is really...


Solution

  • You don't name the parameters in your routerLink attribute, just pass in the values:

    [routerLink]="['/profiles', 'president', 'obama', 1]"
    

    For /profiles/:id/edit:

    [routerLink]="['/profiles', id, 'edit']"