Relative Content

Tag Archive for javascriptangulartypescriptangular-routing

Angular: Scroll to a section on page load when navigating to a specific URL fragment

I’m working on an Angular application and I have a function that scrolls smoothly to a specific section on the page. The function works perfectly when I trigger it manually. However, I want the page to automatically scroll to a specific section when the user navigates directly to a URL with a fragment, such as http://localhost:4200/section-2.