Gregg Gregg - 6 months ago 30
AngularJS Question

Angular 2 routerLink With Semantic URL

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.

Answer
<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.