1

I'm trying to build a routerLink on a list page.

I have a Route defined like so:

{ path: '/brands/:brandId/regions', component: RegionListComponent }

The end result link would look like this:

<a href="/brands/100/regions">Brand Regions</a>

I'm trying to figure out how to write the routerLink:

<a [routerLink]="['/brands/?????'], ????">regions</a>

The above link shows up in a table so the brandId would be based on an ngFor iteration.

The ???? are where I'm not sure quite what to do.

Gregg
  • 34,973
  • 19
  • 109
  • 214

1 Answers1

1
<a [routerLink]="['/brands/' + item.id + '/regions']">regions</a>

or

<a [routerLink]="['/brands', item.id, 'regions']">regions</a>

depending if the route segments are on different components or all on the root component.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567