【问题标题】:Use named router-outlet for a lazy loaded or child module为延迟加载或子模块使用命名路由器出口
【发布时间】:2019-01-14 16:22:51
【问题描述】:

我正在尝试加载顶部带有配置栏的页面。每个页面都有不同的配置设置,它们是页面的子级。

我的 app.component.html 有

<router-outlet name="config"></router-outlet>
<router-outlet></router-outlet>

我的 app-routering.module.ts 有

const routes: Routes = [
  { path: 'LastTradedPrices', component: LastTradedPricesComponent }

  { path: 'Slippage/:group', loadChildren: './slippage/slippage.module#SlippageModule' }
];

这是 SlippageComponent 的路线

const slippageRoutes: Routes = [
    { 
        path: '', 
        component: SlippageComponent,
        children: [
            {
                path: '',
                component: ConfigComponent,
                outlet: 'config'
            }
        ] 
    }
];

基本上,我希望默认插座显示来自 SlippageComponent 的页面数据,并将 ConfigComponenet 加载到其上方命名的“配置”插座中。

【问题讨论】:

    标签: angular angular-ui-router angular-components


    【解决方案1】:

    子组件ConfigComponent在父组件SlippageComponent中寻找router-outlet

    对于给定的 app.component.html,如下更改 Slippage 路线。

    const slippageRoutes: Routes = [
      {
        path: '',
        component: ConfigComponent,
        outlet: 'config'
      },
      {
        path: '',
        component: SlippageComponent,
      }
    ];
    

    【讨论】:

      猜你喜欢
      • 2017-12-07
      • 2023-04-08
      • 2019-12-07
      • 1970-01-01
      • 1970-01-01
      • 2017-08-21
      • 2022-11-03
      • 1970-01-01
      • 2020-10-01
      相关资源
      最近更新 更多