How to open routerlinks in a new tab with middle click mouse in Angular 6? I want to open every link in a new tab. for example
<button mat-icon-button color="accent" [routerLink]="['/edit', a.Id]">
<mat-icon>edit</mat-icon>
</button>
The auxclick event is fired when a any non-left mouse button has been pressed and released on an element.
<button mat-icon-button color="accent" [routerLink]="['/edit', a.Id]"
(auxclick)="onClick($event)">
<mat-icon>edit</mat-icon>
</button>
component.ts
onClick(e){
e.preventDefault();
if(e.which==2){
window.open('/users/'+a.Id);
}
}
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