Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
Say hello to Angular's future home!Check out Angular.devHome
/

withNavigationErrorHandler

Subscribes to the Router's navigation events and calls the given function when a NavigationError happens.

See more...

      
      withNavigationErrorHandler(fn: (error: NavigationError) => void): NavigationErrorHandlerFeature
    
Parameters
fn (error: NavigationError) => void
Returns

NavigationErrorHandlerFeature: A set of providers for use with provideRouter.

See also

Description

This function is run inside application's injection context so you can use the inject function.

Further information is available in the Usage Notes...

Usage notes

Basic example of how you can use the error handler option:

      
      const appRoutes: Routes = [];
bootstrapApplication(AppComponent,
  {
    providers: [
      provideRouter(appRoutes, withNavigationErrorHandler((e: NavigationError) =>
inject(MyErrorTracker).trackError(e)))
    ]
  }
);