如何延迟加载子路由? [英] How to lazy load children routes?

查看:37
本文介绍了如何延迟加载子路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这样配置我的路由:

I would like to configure my routing like this:

const routes: Routes = [
    {
        path: ':angebotsNummer',
        loadChildren: './uebersicht/uebersicht.module#UebersichtModule',
        resolve: { angebotReadModel: AngebotReadModelResolver },
        children: [
            {   path: 'konditionen',
                loadChildren: './konditionen/konditionen.module#KonditionenModule',
            }
        ]
    }
]

这将导致子网址 :angebotsNummer/konditionen

这样做,角度告诉我:错误:路由':angebotsNummer'的配置无效:children和loadChildren不能一起使用

所以这行不通.如果有的话,我如何以角度延迟加载 childrenroutes?

So this will not work. How can I lazy load childrenroutes in angular, if at all?

推荐答案

在这种情况下,您将在惰性模块路由 (Uebersicht-routing.module.ts) 中添加该配置

In that case you would add that configuration in the lazy module routing (Uebersicht-routing.module.ts)

const routes: Routes = [
{
    path: '',
    children: [
        {   path: 'konditionen',
            loadChildren: './konditionen/konditionen.module#KonditionenModule',
        }
    ]
}]

并删除您拥有的孩子部分:

And remove the children part you have:

const routes: Routes = [
    {
        path: ':angebotsNummer',
        loadChildren: './uebersicht/uebersicht.module#UebersichtModule',
        resolve: { angebotReadModel: AngebotReadModelResolver }
    }]

这篇关于如何延迟加载子路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆