I would like to use fragment routing to a page in my navigation. Actually it works fine if the page is fully loaded. Unfortunatelly it does not scroll to the correct position if the page is not yet fully loaded.
This is the code I have adjusted in the app-routing.module.ts:
imports: [RouterModule.forRoot(routes,
{
// configure Router module to handle anchor scrolling with fragment
anchorScrolling: 'enabled',
onSameUrlNavigation: 'reload',
scrollPositionRestoration: 'enabled',
scrollOffset: [0, 80],
})],
exports: [RouterModule]
This is the anchor-tag in my navigation:
<a class="dropdown-item" routerLink="leistungen" fragment='DigitalFramework'>Digitale Methoden | Digitalisierung</a>
And finally the section I would like to scroll:
<section id="DigitalFramework"></section>
This code works fine when I have loaded the page already, if this is not the case I do not scroll to the position I would like to come.
The question is how do I initiate the anchor scrolling only if the page is fully loaded?