延迟加载组件到Angular辅助出口中

时间:2019-01-21 16:19:39

标签: angular router angular-auxiliary-routes

我具有以下路由配置:

const routes: Routes = [
    {
        path: '',
        pathMatch: 'full',
        redirectTo: 'container-page'
    },
    {
        path: 'container-page',
        component: ContainerPage,
        children: [
            {
                path: 'first-page',
                loadChildren: '../first-page/first-page.module#FirstPageModule',
                outlet: 'detail'
            },
        ]
    },

];

如您所见,我正在尝试将组件延迟加载到辅助插座中,但是导航到适当的路径(http://localhost:4200/container-page/(detail:first-page)之后,在有问题的插座内部呈现了ng-component,并在其中一个新的空路由器出口和另一个处于DOM级别的ng组件,这是因为新渲染的路由器出口将ng组件完全隐藏在其级别,并且内容不会显示。

在主要出口中,仅在辅助命名出口中,未记录此行为。有没有人成功地将组件延迟加载到辅助插座中?

1 个答案:

答案 0 :(得分:0)

您不能延迟加载组件,我自己对此有麻烦。您是否为该延迟加载的模块设置了子路由?

相关问题