Search code examples
angulartypescriptangular10routerlink

Angular: Find Full URL String of Sibling Component in Routerlink


How do I find the full Url from a Router Link in Angular? I know how to navigate to a sibling component, however looking for the full url string, to store in variable .

Resources:

how to navigate from sibling component to another sibling component in Angular?

How do I navigate to a parent route from a child route?


Solution

  • You can do the following if you have the array of routes for your sibling route:

       this.router.serializeUrl(this.router.createUrlTree([...routes]))