Try to search your question here, if you can't find : Ask Any Question Now ?

scrollPositionRestoration failing when href is involved – Angular 7

HomeCategory: stackoverflowscrollPositionRestoration failing when href is involved – Angular 7
rupesh asked 2 weeks ago

I am using scrollPositionRestoration() to show always my component from the top of it and it actually works. The problem is when I work in different references on the same component (href) instead of calling routerLink to jump to another component.

Code

<li class="nav-item">
  <a class="nav-link js-scroll-trigger text-warning" href="#ourteam">Our Team</a>
</li>
<li class="nav-item">
   <a class="nav-link js-scroll-trigger text-warning" routerLink="blog">Blog</a>
</li>

Router

@NgModule({
imports: [

    RouterModule.forRoot(routes, { scrollPositionRestoration: "enabled" })
  ],
  exports: [RouterModule]
})

on this case it would work for routerLink but not for href. What happens when I click on ourTeam is that I need to click on it twice (I guess it is just cause in the first time I scroll to the top of the component using scrollPositionRestoration on the router, and in the second time being on the same component I do not need to call to the router so I do not call to scrollPositionRestoration )

1 Answers
Best Answer
Matthias answered 2 weeks ago
Your Answer

16 + 3 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com