With Angular2, how would I retrieve the current active component and path?
For example I might have the following routes:
{ path: \'\', component:
Yes you can check current active component using router snapshot-
import { Router,ActivatedRoute } from '@angular/router';
constructor(public route : ActivatedRoute) {
var snapshot = route.snapshot;
console.log(snapshot._routeConfig.component.name); //This will give you the name of current active component
}
Note- snapshot._routeConfig.component.name it will give you the active component name, and if you want url you can also get it by .url instead of name