function
Subscribes to the Router's navigation events and calls the given function when a NavigationError happens.
withNavigationErrorHandler(fn: (error: NavigationError) => void): NavigationErrorHandlerFeature fn | (error: NavigationError) => void |
NavigationErrorHandlerFeature: A set of providers for use with provideRouter.
This function is run inside application's injection context so you can use the inject function.
Further information is available in the 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)))
]
}
);
© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/router/withNavigationErrorHandler