0

I want to access a component's routing URL that is not the current url and store it in a service. So basically if my component is parentComponent and has childComponent then the URL of the child component is

/parentComponent/childComponent

If I navigate to the above URL and call this.router.url in parentComponent's ngOnInit then it correctly returns /parentComponent/childComponent. How do I get just /parentComponent, i.e. the route to the component itself, from the router within the parent component?

tomcek112
  • 1,516
  • 10
  • 16

1 Answers1

0

this.router.parent.url will return parent url and it's params.

Nikhil Chandu
  • 421
  • 3
  • 10