W3cubDocs

/Angular

OnSameUrlNavigation

type-alias

How to handle a navigation request to the current URL. One of:

See more...

type OnSameUrlNavigation = 'reload' | 'ignore';

See also

Description

  • 'ignore' : The router ignores the request it is the same as the current state.
  • 'reload' : The router processes the URL even if it is not different from the current state. One example of when you might want this option is if a canMatch guard depends on application state and initially rejects navigation to a route. After fixing the state, you want to re-navigate to the same URL so the route with the canMatch guard can activate.

Note that this only configures whether the Route reprocesses the URL and triggers related action and events like redirects, guards, and resolvers. By default, the router re-uses a component instance when it re-navigates to the same component type without visiting a different component first. This behavior is configured by the RouteReuseStrategy. In order to reload routed components on same url navigation, you need to set onSameUrlNavigation to 'reload' and provide a RouteReuseStrategy which returns false for shouldReuseRoute. Additionally, resolvers and most guards for routes do not run unless the path or path params changed (configured by runGuardsAndResolvers).

© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/router/OnSameUrlNavigation