问题描述
如何从Angular的路由器链接中找到完整的网址? 我知道如何导航到同级组件,但是要查找完整的URL字符串以存储在变量中。
资源:
how to navigate from sibling component to another sibling component in Angular?
How do I navigate to a parent route from a child route?
解决方法
如果具有用于同级路由的路由数组,则可以执行以下操作:
this.router.serializeUrl(this.router.createUrlTree([...routes]))