Reputation: 61
I got a case, where I need to intercept click event and pick some additional config object from component it has routerLink attribute. How to determine if component has any? There is elementRef.nativeElement.attributes.ng-reflect-router-link
but I believe, there is a better way to achieve that. Or, how to determine which selector was used to match element in my click-handler Directive - that would answer my question as well.
Upvotes: 2
Views: 322
Reputation: 911
You can add a click event to your links which have a routerLink
attribute. Take a look at the following answer: https://stackoverflow.com/a/36214759/8843654
Your links would look something like this: <a [routeLink]=['User'] (click)="myCallback()">User</a>
Upvotes: 2