With previous angular2 routers, I were able to get component name by url.
console.log(this.router.instruction);
console.log(this.router.currentInstruction.component);
console.log(this.router.currentInstruction.component.routeName);
But with new Router I can't. Is there any alternatives?
I want to track every routing in my app, then will log it with it's component name(not url value)
constructor(private router: Router,
private cookieService: CookieService,
private adminService: AdminService,
private appService: AppService) {
router.events.subscribe((e: Event) => {
if (e instanceof NavigationEnd) {
//
// WANT TO GET COMPONENT NAME by this.router.url
//
let newRoute = this.router.url || '/';
if (this.currentRoute != newRoute) {
console.log('route to ', newRoute);
this.currentRoute = newRoute;
}
}
});
}
any chance?