Angular Routing with Fragment Hash doesn't work if I click the same anchor twice

Discussão em 'Angular' iniciado por Saad Bashir, Março 16, 2025.

  1. Saad Bashir

    Saad Bashir Guest

    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.

    Continue reading...

Compartilhe esta Página