Extra configuration options that can be used with the withRouterConfig function.

interface RouterConfigOptions {
  canceledNavigationResolution?: 'replace' | 'computed'
  onSameUrlNavigation?: OnSameUrlNavigation
  paramsInheritanceStrategy?: 'emptyOnly' | 'always'
  urlUpdateStrategy?: 'deferred' | 'eager'

Child interfaces


Property Description
canceledNavigationResolution?: 'replace' | 'computed'

Configures how the Router attempts to restore state when a navigation is cancelled.

'replace' - Always uses location.replaceState to set the browser state to the state of the router before the navigation started. This means that if the URL of the browser is updated before the navigation is canceled, the Router will simply replace the item in history rather than trying to restore to the previous location in the session history. This happens most frequently with urlUpdateStrategy: 'eager' and navigations with the browser back/forward buttons.

'computed' - Will attempt to return to the same index in the session history that corresponds to the Angular route when the navigation gets cancelled. For example, if the browser back button is clicked and the navigation is cancelled, the Router will trigger a forward navigation and vice versa.

Note: the 'computed' option is incompatible with any UrlHandlingStrategy which only handles a portion of the URL because the history restoration navigates to the previous place in the browser history rather than simply resetting a portion of the URL.

The default value is replace when not set.

onSameUrlNavigation?: OnSameUrlNavigation

Configures the default for handling a navigation request to the current URL.

If unset, the Router will use 'ignore'.

See also:

paramsInheritanceStrategy?: 'emptyOnly' | 'always'

Defines how the router merges parameters, data, and resolved data from parent to child routes. By default ('emptyOnly'), inherits parent parameters only for path-less or component-less routes.

Set to 'always' to enable unconditional inheritance of parent parameters.

Note that when dealing with matrix parameters, "parent" refers to the parent Route config which does not necessarily mean the "URL segment to the left". When the Route path contains multiple segments, the matrix parameters must appear on the last segment. For example, matrix parameters for {path: 'a/b', component: MyComp} should appear as a/b;foo=bar and not a;foo=bar/b.

urlUpdateStrategy?: 'deferred' | 'eager'

Defines when the router updates the browser URL. By default ('deferred'), update after successful navigation. Set to 'eager' if prefer to update the URL at the beginning of navigation. Updating the URL early allows you to handle a failure of navigation by showing an error message with the URL that failed.

© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.