无法路由到指定的插座 Angular 10

cannot route to named outlet Angular 10

提问人:Mauricio Buitrago 提问时间:6/6/2023 更新时间:6/6/2023 访问量:17

问:

我有一个应用程序,该应用程序有一个用于页面主要部分的路由器和另一个用于聊天的路由器。在我的 app.routing 中:

const routes: Routes = [
  {
    path: 'start',
    canActivate: [AuthGuard],
    loadChildren: () =>
      import('./pages/start.module').then((m) => m.StartModule),
  },
  { path: 'login/:place', component: AuthComponent },
  { path: 'public/:id/:token', component: PublicComponent },
  { path: '404', component: NotFoundComponent },
  { path: '', redirectTo: 'login/admin', pathMatch: 'full' },

  { path: '**', component: NotFoundComponent },
];

在 mi start.routing 中:

const routes: Routes = [
  {
    path: '',
    canActivate: [AuthGuard],
    component: SidenavComponent,
    data: { title: 'start' },
    children: [
      {
        path: 'modulos/:module',
        canActivate: [AuthGuard],
        loadChildren: () =>
          import('./modulos/modulos.module').then((m) => m.ModulosModule),
      },
      {
        path: 'msg',
        canActivate: [AuthGuard],
        loadChildren: () =>
          import('../components/comunication/chat/chat.module').then(
            (m) => m.ChatModule
          ),
        outlet: 's',
      },
    ],
  },
];```

and in my start.html:


<button [routerLink]=“['start',{ outlets: { s: ['msg'] } }]” >chat

<router-outlet></router-outlet>

  <div>
    <router-outlet name='s'></router-outlet>
  </div>
I click on the button to navigate at chat I get the following error:


错误:未捕获(在 promise 中):错误:无法匹配任何路由。URL 段:“msg” 错误:无法匹配任何路由。URL 段:“msg”


I thank you for your help


I have an app in Angular 10, the app has two router-outlets. The first router-outlet is for the main part of the page and another router for a chat. but When I click on the button to navigate at chat I get the following error:

Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'msg'
Error: Cannot match any routes. URL Segment: 'msg'
angular 模块 命名路由

评论

0赞 Community 6/7/2023
请澄清您的具体问题或提供其他详细信息,以准确说明您的需求。正如目前所写的那样,很难确切地说出你在问什么。

答: 暂无答案