I have an Angular application where I need to reload the page after navigation. I tried using this solution, but the window.location.reload();
method does not work in production. As a workaround, I added useHash: true
in the app-routing.module.ts
file. However, this approach causes issues when implementing SSR in the application. So I am looking for an alternative way to achieve the same result as shown below:
this.router.navigate(['path/to'])
.then(() => {
window.location.reload();
});
I have also attempted to use
window.location.href = window.location.href
and window.location.href = window.location.protocol + '//' + window.location.host + '/path/to';
instead of window.location.reload();
, but none of these methods reload the page as expected.
Is there another approach to reloading the page after navigating in Angular 12? Any help or guidance would be appreciated.
Edit : Why reloading is needed: After a user logs in, notifications are displayed in the header. These notifications do not appear unless the page is manually reloaded.