Angular2如何直接进入延迟加载模块?

前端之家收集整理的这篇文章主要介绍了Angular2如何直接进入延迟加载模块?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我得到以下结构:

+--AppModule
|  +--OverviewModule
|  |  +--OtherModule1
|  |  +--OtherModule2
|  |  +--OtherModule3

要加载OverviewModule,我使用延迟加载.这是我的AppModule路由配置:

const appRoutes: Routes = [
    {
        path: 'overview',loadChildren: 'app/injus/views/overview.module#OverviewModule'
    },{
        path: '',redirectTo: 'overview',pathMatch: 'full'
    },{
        path: '**',component: PageNotFoundComponent
    }
];

当路径为“概览”时,它将显示我的概览模块.当路径”我希望它去’概述’.不幸的是,这不起作用.

概述路由:

export const overviewRoutes: Routes = [
    {
        path: '',component: OverviewComponent,children: [
            {
                path: '',redirectTo: 'othermodule1',pathMatch: 'full'
            },{
                path: 'othermodule1',loadChildren: 'app/injus/views/othermodule1/othermodule1.module#otherModule1'
            },{
                path: 'othermodule2',loadChildren: 'app/injus/views/othermodule2/othermodule2.module#2otherModule1'
            },{
                path: 'othermodule3',loadChildren: 'app/injus/views/othermodule2/othermodule3.module#3otherModule1'
            }
        ]
    }
];

如何指向延迟加载的模块?

解决方法

请尝试它应该工作:

导出const overviewRoutes中的主要问题:Routes = []

export const overviewRoutes: Routes = [
     {
        path: '',},children: [
            {
                path: 'othermodule1',loadChildren: 'app/injus/views/othermodule2/othermodule3.module#3otherModule1'
            }
        ]
    }
];

Routes = [ 
     {
        path: '',}
    ....
   ]

去掉

children: [{
       path: '',....
   ]

猜你在找的Angularjs相关文章