What I did was navigating to the same URL I'm on:
this.router.navigate([this.router.url]);
but in order to trigger the resolvers runGuardsAndResolvers: 'always'
had to be added to route config and onSameUrlNavigation: 'reload'
to app-routing.module
:
@NgModule({
imports: [
RouterModule.forRoot(
[
{ useHash: true, enableTracing: DEBUG_INFO_ENABLED, onSameUrlNavigation: 'reload', scrollPositionRestoration: 'disabled' }
)
],
What is worth noticing is scrollPositionRestoration: 'disabled'
which keeps my scroll position intact. I've read that it's available since Angular 6.1.
Instead of adding those configs above you can add refresh=1
or similar to your URL so the resolvers would get triggered out of the box.
Inspired by SO answers.