I am trying to redirect within the page, using a fragment in an anchor tag. It works fine the first time but when I scroll the page up manually and press the anchor link again it doesn't work.
<a class="nav-link page-scroll" [routerLink]="['/']" fragment="home">Home</a>
<a class="nav-link page-scroll" [routerLink]="['/']" fragment="about">About</a>
I have uploaded my code on StackBlitz
Click on About and you will see the page scroll. Scroll up manually and press About again, this time nothing will happen. I'm looking forward to your suggestions on how to fix this.
href="#fragment
does not work well with thebase href
that is regularly used in agular routing (see rogerkeays.com/blog/using-base-href-with-anchors) – Immoralist