If you have Angular 5 or above, just change
<a href="" (click)="passTheSalt()">Click me</a>
into
<a [routerLink]="" (click)="passTheSalt()">Click me</a>
A link will be displayed with a hand icon when hovering over it and clicking it won't trigger any route.
Note: If you want to keep the query parameters, you should set queryParamsHandling
option to preserve
:
<a [routerLink]=""
queryParamsHandling="preserve"
(click)="passTheSalt()">Click me</a>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…