【发布时间】:2020-06-26 07:15:47
【问题描述】:
我正在从后端应用程序接收路由通知,以加载 Angular 组件。示例:
// Current route "/example1/path1"
let route = "/example2/path1"; //route received from back-end
this.router.navigate([route]); // OK: navigates to component associated to "/example2/path1" path
此外,在每个组件中,我都在订阅中处理路由通知:
this.route.params.subscribe(params => {
...
}
});
尽管如此,我在某些接收到的路线上导航到同一组件时遇到了一些麻烦,比如说:
// Current route "/example1/path1"
let route = "/example1/path1"; //route received from back-end (SAME ROUTE PATH)
this.router.navigate([route]); // NOK: route notification not received in subscription
我的问题是:当应用程序需要导航到相同的路线时,是否有任何方法可以接收此订阅通知?查询参数对我来说是一个有效的解决方案,例如:“/example1/path1?timestamp=1234567”,但是我不知道如何在不创建单独的解析方法的情况下分别解析“timestamp”和“path1”......
如果您对此提供任何帮助或建议,我将不胜感激。
【问题讨论】:
标签: angular typescript routes angular-routing angular-router