代码之家  ›  专栏  ›  技术社区  ›  user8216014

角度5定义模块内的子管线

  •  0
  • user8216014  · 技术社区  · 8 年前

    我有以下结构的Angular 5应用程序:

    /-app module
       /--- settings dashboard component
    /-settings A module
       /--- list A component
       /--- edit A component
    /-settings B module
       /--- list B component
       /--- edit B component
    

    我要设置此模块和组件的路由:

    'settings' -> settings dashboard component (defined in app-routing.module.ts)
    'settings/A' -> list A component (defined in a-routing.module.ts)
    'settings/A/edit' -> list A edit component (defined in a-routing.module.ts)
    'settings/B' -> list B component (defined in b-routing-module.ts)
    'settings/B/edit' -> list B edit component (defined in b-routing-module.ts)
    

    有可能吗?我试着和孩子们组合路线,但不起作用。

    1 回复  |  直到 8 年前
        1
  •  0
  •   Joo Beck    8 年前

    好吧,我明白你的担忧,但是的,这是可能的。

    应用程序路由。单元

    const routes: Routes = [{
      path: 'settings',
      component: SettingsDashboardComponent
    }, {
      path: 'settings/A',
      loadChildren: './a/a.module#AModule'
    }, {
      path: 'settings/B',
      loadChildren: './b/b.module#BModule'
    }];
    

    a-布线。单元

    const routes: Routes = [{
      path: '',
      component: AListComponent
    }, {
      path: 'edit',
      component: AEditComponent
    }];
    

    b路由就像a路由。

    这条路线包含另一条路线的一部分这一事实无关紧要,它是完全匹配的。它确实关心延迟加载的部分,但仅限于它能够匹配延迟加载路由中某个地方的完整路由。

    推荐文章