Angular 12 Error: Cannot match any routes. Navigate to named outlet NgRx Effect

Angular 12 Error: Cannot match any routes. Navigate to named outlet NgRx Effect

我正在使用带参数的命名路由器插座,我需要从效果导航到它,但我遇到了错误。

NgRx Router Store 能解决这个问题吗? 或者我需要商店内的旗帜,然后 select 它并在管道中进行导航吗?


我的代码:

在我的路由模块中,到指定出口的路由被声明为子节点。

...
path: '',
    component: SomeComponent,
    children: [
      {
        ...
      },
      {
        path: 'right/:elementId',
        component: RightContainerComponent,
        outlet: 'right-outlet',
      },
...

然后我调用路由器导航为:this.router.navigate([{outlets: {'right-outlet': ['right', itemId]}}], {relativeTo: this.route});

此外,我从 NgRx Effect 中进行导航,我认为它在那里我失去了 relativeTo.

的上下文

完整的错误日志:

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'right/some_id'
Error: Cannot match any routes. URL Segment: 'right/some_id'
    at ApplyRedirects.noMatchError (router.js:2658:1)
    at router.js:2640:1
    at catchError.js:10:38
    at OperatorSubscriber._error (OperatorSubscriber.js:19:1)
    at OperatorSubscriber.error (Subscriber.js:40:1)
    at OperatorSubscriber._error (Subscriber.js:64:1)
    at OperatorSubscriber.error (Subscriber.js:40:1)
    at OperatorSubscriber._error (Subscriber.js:64:1)
    at OperatorSubscriber.error (Subscriber.js:40:1)
    at OperatorSubscriber._error (Subscriber.js:64:1)
    at resolvePromise (zone.js:1213:1)
    at resolvePromise (zone.js:1167:1)
    at zone.js:1279:1
    at ZoneDelegate.invokeTask (zone.js:406:1)
    at Object.onInvokeTask (core.js:28667:1)
    at ZoneDelegate.invokeTask (zone.js:405:1)
    at Zone.runTask (zone.js:178:1)
    at drainMicroTaskQueue (zone.js:582:1)
    at ZoneTask.invokeTask [as invoke] (zone.js:491:1)
    at invokeTask (zone.js:1600:1)

那里有很多问题,虽然最主要的是我试图从服务路由到指定的出口,但你无法从那里访问路由的当前部分,因为活动路由只是根.

void this.router.navigate([{ outlets: { right: ['111'] } }], {
                relativeTo: this.route.parent, //this is important to set the context
              });

此代码进入我创建子路由的模块中的组件。