7

How can I use routerLinkActive with click event and without routerLink? I read somewhere that using click and routerLink together is not a good practice. I want to set an active class when I click the link and want to perform some business functions on click event before navigating the user to the clicked page. The code below is not setting the class.

<button
    type="button"
    class="list-group-item list-group-item-action"
    routerLinkActive="active"
    *ngFor="let service of services"
    (click)="changeService(service)">
    {{ service | titlecase }}
</button>
Pritam Bohra
  • 3,912
  • 8
  • 41
  • 72

0 Answers0