我需要将ActiveRoute传递给RouterExtensions.navigate()relativeTo参数。
this.routerExtensions.navigate(['page', {relativeTo: this.activeRoute}]);
我正在使用以下代码来观察可观察到的PageRoute.activatedRoute参数,但我无法弄清跟踪ActivateRoute可观察自身所需的操作。
constructor(private pageRoute: PageRoute, private routerExtensions: RouterExtensions) {
this.pageRoute.activatedRoute.pipe(
switchMap(activatedRoute => activatedRoute.params))
.forEach((params) => {
this.id = +params["id"];
}
);
}
我尝试使用Tap来跟踪activateRoute,但是它无法解析URL:
JS: ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'page'
tap
的示例:
constructor(private pageRoute: PageRoute, private routerExtensions: RouterExtensions) {
this.pageRoute.activatedRoute.pipe(
tap(activatedRoute => this.activatedRoute = activatedRoute),
switchMap(activatedRoute => activatedRoute.params))
.forEach((params) => {
this.id = +params["id"];
}
);
}