Angular:参数无效:“...”的路由生成器未包含在传递的参数中

Angular: Invalid argument(s): Route generator for "..." was not included in parameters passed

我正在使用带参数的子路由配置(AngularDart,包angular_router:^1.0.2)并发生以下错误:

EXCEPTION: Invalid argument(s): Route generator for "chave" was not included in parameters passed.

我做错了什么?

@RouteConfig 定义是:

根目录

@RouteConfig(const [
  const Redirect(path: '/', redirectTo: const ['Painel']),
  const Route(path: '/painel', name: 'Painel', component: PainelComponent, useAsDefault: true),
  const Route(path: '/empresas/...', name: 'Empresas', component: EmpresasComponent),
  const Route(path: '/iniciativas', name: 'Iniciativas', component: IniciativasComponent),
])

In Parent EmpresasComponent (pass param to child EmpresaDetalheComponent)

@RouteConfig(const [
  const Route(path: '/empresa/:chave', name: 'EmpresaDetalhe', component: EmpresaDetalheComponent,
      useAsDefault: true),
])

当从 Root basead 配置定义调用 Parent 时,即使没有调用具有参数的子项,也会出现问题。

详情:

导航应该是这样的: 根目录 >>> 父目录 >>> 子目录(有参数)= OK

但是这里需要传参:Root >>> Parent = Error,连parent都不传参数,只有child需要

我做错了什么?

我找到了这个问题的原因。

实际上,如果 useAsDefault: true 在带有参数 (p.e. /:param) 的路由 URL 中,就会出现此问题。

解决方法是将另一个路由 URL 不带 参数定义为 useAsDefault: true