如何处理angular5个递归的未知确切数目路由器参数?

How to handle angular 5 recursive unknown exact number router parameters?

有没有办法处理递归未知的路由器参数的确切数量?

例如:

我们有产品类别,产品类别可以有子类别,子类别可以有自己的子类别等等。主要有几个条件:

检查和重定向的解决方案是使用路由器解析器。但是如何在路由模块中跟踪这些 url?

从我的角度来看,路线应该是这样的:

{
  path: '/categories/:id',
  component: SubcategoriesListComponent
},
{
  path: '/categories/:id/**/:id',
  component: SubcategoriesListComponent,
},
{
  path: '/categories/:id/**/:id/items',
  component: CategoryItemsListComponent
}

是否可以这样实现?

无组件路由的可能解决方案: 在路由配置中

{
    path: 'categories/:id', children: [
    {path: '**', component: SubcategoriesListComponent}
]
}

在组件文件中:

export class SubcategoriesListComponent {

  constructor(aroute: ActivatedRoute) {
    aroute.url.subscribe((data) => {
      console.log('params ', data); //contains all the segments so put logic here of determining what to do according to nesting depth
    });

  }

}

这是 output example(我在我的项目 ErrorComponent 上测试过所以不要混淆)