My angular application contains an anchor tag which has a routerLink and click handler associated with it:
<a [routerLink]="/abc" (click)="onClick"> </a>
I would like the routerLink to be used when the user right-clicks and selects "Open in New Tab".
The click handler should be triggered if the user simply left-clicks on the link. In this case I do NOT want the routerLink to trigger a route change.
Within my click handler I have tried aborting the click event, i.e.
public onClick(event: MouseEvent): {
// Was hoping this would do it...
event.preventDefault();
// .. clutching at straws
event.stopPropagation();
// .. oh dear oh dear. Still not working
event.stopImmediatePropagation();
}
None of these are preventing the routerLink from activating and navigating the the new route /abc. How can I have my click handler prevent the routerLink from being fired?