withNavigationErrorHandler
Subscribes to the Router's navigation events and calls the given function when a
NavigationError
happens.
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)))
]
}
);