I have problem. On my page, I have route /productsList. And I have list-group :
<div class="sticky-top">
<ul class="list-group">
<a class="list-group-item list-group-item-action" [routerLink]="['/productsList']" routerLinkActive="active" > sad</a>
<a *ngFor="let products of categoryProduc; let i = index" [routerLink]="[products.name]" routerLinkActive="active" class="list-group-item list-group-item-action">
{{ products.name }}
</a>
</ul>
</div>
When I click on the some Item of list, route is changed example: /productsList/product and item is selected, but my :
<a class="list-group-item list-group-item-action" [routerLink]="['/productsList']" routerLinkActive="active" > sad</a>
Is always selected because I always have /productsList, I want when I have nested route to be disable.
You have to define [routerLinkActiveOptions]="{ exact: true }" to make the difference between /productsList and /productsList/product:
<a class="list-group-item list-group-item-action" [routerLink]="['/productsList']" routerLinkActive="active" [routerLinkActiveOptions]="{ exact: true }">not sad</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With