I want to disable changing the URL when routing in my Angular 2 app.
I know that skipLocationChange: true
has to be passed as a NavigationExtras
parameter to the router.
My question is:
Is it possible to pass NavigationExtras to a routerLink from inside the template?
What I have tried:
<h1>
{{title}}
</h1>
<ul>
<li><a [routerLink]="['route1', { skipLocationChange: true }]">Route1</a></li>
<li><a [routerLink]="['route2', { skipLocationChange: true }]">Route2</a></li>
</ul>
<router-outlet></router-outlet>
but it does not work.
After clicking a link, the route changes to http://localhost:4200/route2;skipLocationChange=true
I don't want to use this.router.navigate(['route1], {skipLocationChange: true)
in my controller, since then I lose routerLinkAtive
highlighting.