Suppose I have two routes :
{ path: '/path1', component: component1 }
{ path: '/path2', component: component2 }
and I am at '/path1' and navigating to '/path2'.
So my question is how get route url '/path1' in component 2 constructor or anywhere in code without using resolve or global variable through any service.
Component2.ts
export class Component2{
constructor(router: Router) {
router.events.subscribe((event) => {
// here I want to get route url '/path1' from component1
});
}
}
Please let me know if anyone needs more clarification.