如何在 Angular 2 中跟踪路由? [英] How to trace routing in Angular 2?
本文介绍了如何在 Angular 2 中跟踪路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个单独的路由设置文件的组件:
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 { }
当我输入 URL 地址时:http://localhost:4200/calendar
我被重定向到主页.
When I typing URL address: http://localhost:4200/calendar
I am redirected to home page.
如何在 Angular 2 中跟踪路由?
How can I trace routing in Angular 2?
推荐答案
imports: [
RouterModule.forRoot(
routes,
{ enableTracing: true } // <-- debugging purposes only
)
]
Angular 将根据文档将所有事件记录到浏览器的控制台:
Angular will then log all events to the browser's console, per the documentation:
启用跟踪?:布尔
当为 true 时,将所有内部导航事件记录到控制台.用于调试.
enableTracing?: boolean
When true, log all internal navigation events to the console. Use for debugging.
这篇关于如何在 Angular 2 中跟踪路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文