How can I get the static route path of the current router-outlet component, what was activated by angular in router events?
I need it in app.component, because it would be redundant if I have to do in all component with activatedRoute.snapshot
self.router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
//I need here the path of route E.G '/page/:id/' from root
}
});
Update: In routing:
export const MAIN_ROUTES: Routes = [
{ path: '', component: HomePage },
{ path: 'something', component: SomethingComponent },
{ path: 'page/:id', component: PageComponent }, //if the url is 'example.com/page/someId' than, I want to get the "path" field of this object and if I change the page, I need that inside the router event above.
]