另一个具有ID的孩子在app-routing.module.ts角度9中不起作用

问题描述 投票:0回答:1

例如有效!

  { path: 'products/:id', component: ItemComponent, 
    children: [

      { path: 'gallery', component: GalleryComponent } 

  ] }, 

  { path: 'products', component: ProductsComponent },


   http//localhost:4200/products   --->  (ProductsComponent)  works!
   http//localhost:4200/products/1   ---> (ItemComponent) works!
   http//localhost:4200/products/1/gallery --->(GalleryComponent) works!

但是...在同一文件中不起作用!

   { path: 'category/:id', component: SinglecategoryComponent, 
    children: [
      { path: 'sub', component: SubcategoryComponent } 

   ] },

   { path: 'category', component: CategoryComponent },

   http//localhost:4200/category    --->  (CategoryComponent )  works!
   http//localhost:4200/category/1   ---> (SinglecategoryComponent) works!
   http//localhost:4200/products/1/sub  --->(SinglecategoryComponent) ¿? Not works!

Alguna的主意?

   http//localhost:4200/products/1/sub  

应显示

   SubcategoryComponent 

但应显示

  SinglecategoryComponent 

知道发生什么了吗?

angular router children
1个回答
0
投票
此网址http // localhost:4200 / products / 1 / sub不正确吗?根据您的路由配置,它应该是http // localhost:4200 / category / 1 / sub。
© www.soinside.com 2019 - 2024. All rights reserved.