How to trace routing in Angular 2?

OPV picture OPV · Aug 14, 2017 · Viewed 30.6k times · Source

I have component with separated file of routing settings:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { Route } from '../core/route.service';
import { extract } from '../core/i18n.service';
import {CalendarThematicPlanComponent} from './calendar-thematic-plan.component';

const routes: Routes = Route.withShell([
  { path: 'calendar', component: CalendarThematicPlanComponent }
]);

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
  providers: []
})

export class CalendarThematicPlanRoutingModule { }

When I typing URL address: http://localhost:4200/calendar I am redirected to home page.

How can I trace routing in Angular 2?

Answer

devqon picture devqon · Aug 14, 2017

You can pass in a second argument with options:

imports: [
    RouterModule.forRoot(
      routes,
      { enableTracing: true } // <-- debugging purposes only
    )
]

Angular will then log all events to the browser's console, per the documentation:

enableTracing?: boolean
When true, log all internal navigation events to the console. Use for debugging.