W3cubDocs

/Angular

ExtraOptions

interface

A set of configuration options for a router module, provided in the forRoot() method.

interface ExtraOptions extends InMemoryScrollingOptions, RouterConfigOptions {
  enableTracing?: boolean
  useHash?: boolean
  initialNavigation?: InitialNavigation
  bindToComponentInputs?: boolean
  errorHandler?: (error: any) => any
  preloadingStrategy?: any
  scrollOffset?: [...]
  malformedUriErrorHandler?: (error: URIError, urlSerializer: UrlSerializer, url: string) => UrlTree

  // inherited from router/InMemoryScrollingOptions
  anchorScrolling?: 'disabled' | 'enabled'
  scrollPositionRestoration?: 'disabled' | 'enabled' | 'top'

  // inherited from router/RouterConfigOptions
  canceledNavigationResolution?: 'replace' | 'computed'
  onSameUrlNavigation?: OnSameUrlNavigation
  paramsInheritanceStrategy?: 'emptyOnly' | 'always'
  urlUpdateStrategy?: 'deferred' | 'eager'
}

See also

Properties

Property Description
enableTracing?: boolean

When true, log all internal navigation events to the console. Use for debugging.

useHash?: boolean

When true, enable the location strategy that uses the URL fragment instead of the history API.

initialNavigation?: InitialNavigation

One of enabled, enabledBlocking, enabledNonBlocking or disabled. When set to enabled or enabledBlocking, the initial navigation starts before the root component is created. The bootstrap is blocked until the initial navigation is complete. This value is required for server-side rendering to work. When set to enabledNonBlocking, the initial navigation starts after the root component has been created. The bootstrap is not blocked on the completion of the initial navigation. When set to disabled, the initial navigation is not performed. The location listener is set up before the root component gets created. Use if there is a reason to have more control over when the router starts its initial navigation due to some complex initialization logic.

bindToComponentInputs?: boolean

When true, enables binding information from the Router state directly to the inputs of the component in Route configurations.

errorHandler?: (error: any) => any Deprecated

A custom error handler for failed navigations. If the handler returns a value, the navigation Promise is resolved with this value. If the handler throws an exception, the navigation Promise is rejected with the exception.

Deprecated Subscribe to the Router events and watch for NavigationError instead.

preloadingStrategy?: any

Configures a preloading strategy. One of PreloadAllModules or NoPreloading (the default).

scrollOffset?: [ number, number ] | (() => [ number, number ])

Configures the scroll offset the router will use when scrolling to an element.

When given a tuple with x and y position value, the router uses that offset each time it scrolls. When given a function, the router invokes the function every time it restores scroll position.

malformedUriErrorHandler?: (error: URIError, urlSerializer: UrlSerializer, url: string) => UrlTree Deprecated

A custom handler for malformed URI errors. The handler is invoked when encodedURI contains invalid character sequences. The default implementation is to redirect to the root URL, dropping any path or parameter information. The function takes three parameters:

  • 'URIError' - Error thrown when parsing a bad URL.
  • 'UrlSerializer' - UrlSerializer that’s configured with the router.
  • 'url' - The malformed URL that caused the URIError

Deprecated URI parsing errors should be handled in the UrlSerializer instead.

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