How to trace routing in Angular 2?

后端 未结 3 1504
闹比i
闹比i 2020-12-08 06:11

I have component with separated file of routing settings:

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


        
3条回答
  •  余生分开走
    2020-12-08 07:01

    As the comments in the most accepted answer suggest, this enableTracing doesn't work in the forChild method. A simple work around is to subscribe to all routing events in AppModule like so:

    export class AppModule {
    
      constructor(
        private readonly router: Router,
      ) {
        router.events
          .subscribe(console.log)
      }
    
    }
    

提交回复
热议问题