Repository navigation
Description
I have seen quite a few tickets related to this on github, and quite a few posts on this topic involving various workarounds elsewhere on the internet, e.g. on Stack Overflow, but there still doesn't seem to be a proper, simple solution for this included within the framework.
This is my use case:
- I have 2 routes with components - A & B - which share a common parent root (C).
- I have a resolver configured on C. A & B both share the data from this resolver
- In component A, I am performing a server update of the shared data, before navigating to route B.
- When performing this navigation, I want to force the resolver on C to fire again, so that B can see the latest version of the data that has just been modified by A.
Just to be clear:
- I do not want the resolver on C to fire every time I navigate between child routes of C, and I definitely don't want all my other resolvers firing every time I navigate between child routes. So
onSameUrlNavigationis too course a solution for this use case. - I want to be able to force all the resolvers to fire programatically, at the point of navigation, in specific situations as required - i.e. when I have just performed a server update and the route state has not yet been refreshed.
So I am looking for a parameter, or configuration option, that can be passed to Router.navigate() or navigateByUrl() that will force all the resolvers (and probably the guards) in the target route (hierarchy) to be re-executed.
E.g. something like the reload: true option provided in the AngularJS UI router, see here: https://ui-router.github.io/ng1/docs/latest/interfaces/transition.transitionoptions.html#reload - although I believe that also causes all the components to be destroyed and re-created, which is probably not necessary in this case.
Activity
ctaylor-osv commentedon Mar 9, 2020
This issue and #24096 are essentially the same - both are looking for a way to invalidate data from a resolver so that the next time a route is visited, the resolver re-loads the data.
We are in need of this functionality too. Minimally, it would be nice to be able to pass a string or array of strings in
NavigationExtraswhere the strings are keys of resolved data to invalidate/re-run resolvers for.angular-robot commentedon Jun 4, 2021
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
angular-robot commentedon Jun 24, 2021
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
noguespi commentedon Jan 13, 2023
Something similar to the recent onSameNavigationUrl PR #48050 merged in angular 15.1 would be perfect.
For example by adding a
{onSameNavigation: 'reload-all'}parameter.Retriggering/updating resolvers on the same route is definitely something we want to do occasionally and not every time (that's why the custom RunGuardsAndResolvers on the route is not ideal at the moment and having the ability to do it occasionaly on router.navigate is perfect).
The hack I use to force reload parent resolvers when the route doesn't change is to use a custom RunGuardsAndResolvers which detect if there is a _nonce= query parameters in the URL and return true if detected.
When I want to reload the resolvers, I just
router.navigate([], {queryParams: { _nonce: new Date().getTime()}})Erbenos commentedon Jan 14, 2024
Technically this is already possible even without leaking stuff into query params (or any other user observable state) like @noguespi 's solution does, by using the custom route state specified at navigation time. (eg.:
<a routerLink="a" [state]="{ a: true }">Navigate to "a" with resolver refresh</a>) and custom runGuardsAndResolvers strategy.There is couple of issues which make this not very nice however.
injectfunction to resolve the Router. To workaround this you can save the reference to injector at the app startup, eg.: using APP_INITIALIZER.'pathParamsChange' | 'pathParamsOrQueryParamsChange' | 'paramsChange' | 'paramsOrQueryParamsChange' | 'always'strategies as their implementation is not exported by the@angular/routerso at best you either reimplement them or copy/paste the code into your codebase.Demo in stackblitz: https://stackblitz.com/edit/stackblitz-starters-yx7d9d?file=src%2Fmain.ts
3 remaining items
mlpepper commentedon Apr 6, 2024
Is there any update on the state of this?
Would love the ability to refetch a resolver from a child component. e.g.,
Run the resolver on
/users/:idfrom the child route/users/:id/detailsafter a trigger has been executed. This will then allow the childdetailsroute and any others under/users/:idto get the new resolved data without refreshing the page.Mikastark commentedon Jul 15, 2024
I am using the same workaround as @Erbenos, employing a custom runGuardsAndResolvers. While it works, it feels quite hacky and incomplete.
I am eagerly anticipating a more elegant solution—ideally, an option in router.navigate like onSameUrlNavigation: 'reloadGuardsAndResolvers'.
In the meantime, I am considering avoiding the use of resolvers for data that requires reloading. Thoughts?
Erbenos commentedon Jul 15, 2024
Having
onSameUrlNavigation: 'reloadGuardsAndResolvers'.in router.navigate would not allow you to selectively re-resolve subset of resolvers as opposed to all of them. Current API already allows for this (in a way thats not polluting URL anyhow), as my example shows but its quite tedious. The issues I referenced, if addressed, would make it less so.Mikastark commentedon Jul 15, 2024
Perhaps a new option should be considered to explicitly specify which resolver(s) should be triggered again.
atscott commentedon Jan 21, 2025
This is likely something we will be investigating with the integration of resource/signals in the router.
feat(router): Execute RunGuardsAndResolvers function in injection con…
feat(router): Execute RunGuardsAndResolvers function in injection con…
feat(router): Execute RunGuardsAndResolvers function in injection con…
regalialong commentedon Aug 23, 2026
I'm usually allergic about bumping, but since signalizing / resourcing the router is in full swing, is this still considered?
For my use case, I did a mutation on the fetched data, so I know the data on the page is invalid now, but I don't think I can communicate that to the resolver, which is a very annoying gap.
I think #64938 makes Erbenos's solution a bit nicer since you can get the router from DI, but #53946 is still open, so it's still not really clean to reimplement from the user side without copy-paste.
atscott commentedon Aug 24, 2026
This will be marked as resolved when the resource integration is made public. There should be various ways of making this happen, either through reactivity, or through traversing the activated tree and calling
reloadon each of the resources.atscott commentedon Sep 4, 2026
Closing as completed with resource integration that will be available in 22.2 as dev preview. There’s no direct api for this but it should be doable through various mechanisms that feel much better than the previous runGuardsAndResolvers+renavigate
angular-automatic-lock-bot commentedon Oct 24, 2026
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.