繁体   English   中英

Angular route:redirectTo 使用多参数时

[英]Angular route: redirectTo when using multiple param

我有这样的路线

const pipelinesRoutes: Routes = [
  {
    path: ':type',
    component: CatalogComponent,
    canActivate: [LoggedInGuard],
    children: [
      {
        path: '',
        component: CatalogContentComponent,
      },
      {
        path: ':domain/:categoryId',
        component: CatalogContentComponent,
      },
    ],
  },
  { path: '', redirectTo: 'skills', canActivate: [LoggedInGuard] },
];

在这里,如果没有提供类型,我想将我的应用程序重定向到技能(:类型),它在开始时工作正常,但是一旦我刷新说有这个 url。

catalog/skills/technical

它重定向到

catalog/skills/skills/technical

感谢 T. Sunil Rao 帮助我。 是的,我的路线有问题。 我在路由的帮助下传递了空参数

this.router.navigate([domain, ''], { relativeTo: this.route });

但是在刷新时,它不会将该空参数视为参数,因此会重定向。

目录/技能/技术没有完全填充任何路线,因此它重定向到技能/正确的路线应该是

const pipelinesRoutes: Routes = [
  { path: '', redirectTo: 'skills', pathMatch: 'full' },
  {
    path: ':type',
    component: CatalogComponent,
    canActivate: [LoggedInGuard],
    children: [
      {
        path: '',
        component: NoDomainContentComponent,
      },
      {
        path: ':domain',
        component: CatalogContentComponent,
        children: [
          {
            path: ':categoryId',
            component: CatalogContentComponent,
          },
        ]
      },
    ],
  },
];

使用另一个子,因为我不想刷新组件,想使用相同的组件并过滤数据。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM