2017-08-14 81 views
2

我有一個路由設置分隔的文件組成:如何在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 { } 

當我鍵入URL地址:http://localhost:4200/calendar我重定向到主頁。

如何在Angular 2中跟蹤路由?

+0

爲什麼要使用Route.withShell這裏? –

回答

4

您可以通過a second argumentoptions

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

我在哪裏可以看到日誌信息? – OPV

+0

而且我用另一種結構:'@NgModule({ 進口:[RouterModule.forChild(路線), 出口:[RouterModule], 提供商:[] })' – OPV

+0

在瀏覽器的控制檯 – devqon