Angular Snippets

Debugging router events

angular router

For debugging purposes around router events, Angular provides an easy way to log all internal navigation events to the console

const routes: Routes = [];

@NgModule({
  import: [RouterModule.forRoot(routes, { enableTracing: true })],
  exports: [RouterModule],
})
export class AppRoutingModule {}

If your not using an NgModule to bootstrap your app, you can use the withDebugTracing() method

const appRoutes: Routes = [];
bootstrapApplication(AppComponent, {
  providers: [provideRouter(appRoutes, withDebugTracing())],
});
Back to snippets