2017-08-14 1 views
2

Ich habe Komponente mit getrennter Datei von Routing-Einstellungen:Wie verfolgen Sie das Routing in Angular 2?

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 { } 

Wenn ich URL-Adresse eingeben: http://localhost:4200/calendar ich zur Startseite umgeleitet werde.

Wie kann ich das Routing in Angular 2 verfolgen?

+0

Warum verwenden wir Route.withShell hier? –

Antwort

4

Sie können in a second argument mit options passieren:

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

Und wo kann ich Log-Informationen sehen? – OPV

+0

Auch verwende ich eine andere Konstruktion: '@NgModule ({ Importe: [RouterModule.forChild (Routen)], Exporte: [RouterModule], Anbieter: [] })' – OPV

+0

In der Konsole des Browsers – devqon