Angular Routing problem when using useHash:true scrollPositionRestoration: ‘enabled’, did not work

Published

I’m working in an angular project in this project i’m using a routing module to move to a different places in my web page or to anothers componenet the problem is when i move to production mode and i refrech my page after routing i found 404 error page not found that’s why i used useHash:true, the problem was solved but i found another problem scrollPositionRestoration: 'enabled', did not work when i press back button it return me to top of page and i want to return to scroll position but when i delete useHash:true, it works and th is what i found in console wihtout using useHash:true,

Scroll {routerEvent: NavigationEnd, position: Array(2), anchor: '/'}
anchor: "/"
position: Array(2)
0: 0
1: 3026
length: 2
[[Prototype]]: Array(0)
routerEvent: NavigationEnd
id: 3
url: "/#/"
urlAfterRedirects: "/#/"
[[Prototype]]: RouterEvent

and this is what i found using

Scroll {routerEvent: NavigationEnd, position: Array(2), anchor: null}
anchor: null
position: Array(2)
0: 0
1: 2900
length: 2
[[Prototype]]: Array(0)
routerEvent: NavigationEnd
id: 3
url: "/"
urlAfterRedirects: "/"
[[Prototype]]: RouterEvent
[[Prototype]]: Object

and this is how my routes work

 scrollPositionRestoration: 'enabled',
 onSameUrlNavigation: 'reload',
 relativeLinkResolution: 'corrected',
 useHash:true,
 
  scrollOffset: [0, 64],

Source: Angular Questions

Published
Categorized as angular, typescript Tagged ,

Answers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq