Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
This site is no longer updated.Head to Angular.devHome
/

This is the archived documentation for Angular v17. Please visit angular.dev to see this page for the current version of Angular.

NavigationStart

An event triggered when a navigation starts.

      
      class NavigationStart extends RouterEvent {
  constructor(id: number, url: string, navigationTrigger: NavigationTrigger = 'imperative', restoredState: { [k: string]: any; navigationId: number; } = null)
  type: EventType.NavigationStart
  navigationTrigger?: NavigationTrigger
  restoredState?: {...}
toString(): string // inherited from router/RouterEvent constructor(id: number, url: string) id: number url: string }

Constructor

      
      constructor(id: number, url: string, navigationTrigger: NavigationTrigger = 'imperative', restoredState: { [k: string]: any; navigationId: number; } = null)
    
Parameters
id number
url string
navigationTrigger NavigationTrigger

Optional. Default is 'imperative'.

restoredState object

Optional. Default is null.

Properties

Property Description
type: EventType.NavigationStart Read-Only
navigationTrigger?: NavigationTrigger

Identifies the call or event that triggered the navigation. An imperative trigger is a call to router.navigateByUrl() or router.navigate().

See also:

restoredState?: { [k: string]: any; navigationId: number; } | null

The navigation state that was previously supplied to the pushState call, when the navigation is triggered by a popstate event. Otherwise null.

The state object is defined by NavigationExtras, and contains any developer-defined state value, as well as a unique ID that the router assigns to every router transition/navigation.

From the perspective of the router, the router never "goes back". When the user clicks on the back button in the browser, a new navigation ID is created.

Use the ID in this previous-state object to differentiate between a newly created state and one returned to by a popstate event, so that you can restore some remembered state, such as scroll position.

Methods

      
      toString(): string
    
Parameters

There are no parameters.

Returns

string