【问题标题】:Angular route after adding param how we can add sub route添加参数后的角度路由我们如何添加子路由
【发布时间】:2017-12-29 15:19:49
【问题描述】:

例如: 'www.xyz.com/#/indutry/1/subIndustry/2/subSubIndustry/3'

我需要遵循这个结构,我如何才能 ForRoot 我的父路由文件

【问题讨论】:

  • 您使用哪个 Angular 版本?
  • 现在角度为 4

标签: angular angular-routing angular-router


【解决方案1】:

您需要两级嵌套子路由。

确保每条路线都有一个唯一的名称。

您的路线文件。

这个基本示例,取决于您的应用要显示哪种数据。

const routes: Routes = [
  {path: '', redirectTo: 'home', pathMatch: 'full'},
  {path: 'home', component: HomeComponent},
  {
    path: 'indutry/:indutryId',
    component: IndutryComponent,
    children: [
      {path: '', redirectTo: 'subIndustryone', pathMatch: 'full'},
      {
        path: 'subIndustryone/:subindustryOneId', 
        component: SubIndustryOneComponent,
        children : [
          { path : '', redirectTo: 'subIndustrytwo', pathMatch : 'full' },
          { path : 'subIndustrytwo/:subindustryTwoId', component : SubIndustryTwoComponent },
        ]
      },

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

Plunker Example

Blog

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-30
    • 1970-01-01
    • 1970-01-01
    • 2018-08-30
    • 1970-01-01
    • 2020-11-08
    • 2016-03-30
    • 1970-01-01
    相关资源
    最近更新 更多