0

I trying to navigate from a.class1 to div.class2. But the URL is changing when the link is called. So when trying to back page, it goes back to the current page on another section.

<a RouterLink="." [fragment]="'idDiv'" class="class1"></a>
...
<div class="class2" id="idDiv"></div>
  • Does this answer your question? [Anchor fragments in Angular 6](https://stackoverflow.com/questions/52822206/anchor-fragments-in-angular-6) – Drenai Mar 03 '22 at 06:59

1 Answers1

2

Simple add 'skipLocationChange' to your anchor tag

<a routerLink="." [fragment]="'idDiv'" class="class1" skipLocationChange></a>

You can also refer to this one: Angular 2, handle anchor links with href='#'

Anna
  • 259
  • 1
  • 6