我可以使用延迟加载模块创建应用程序的自定义元素吗? [英] Can I create custom element of the application with lazy loading modules?

查看:69
本文介绍了我可以使用延迟加载模块创建应用程序的自定义元素吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Angular中,我有一个应用程序,其中app.module使用延迟加载来加载子模块,并且我希望将该angular应用程序用作自定义元素,以便可以用作其他应用程序的外部组件.

In Angular, I have one application in which app.module use lazy loading to load child modules and I want to use that angular application as a custom element so I can use as an external component to other application.

我知道可以在具有app-root的单独应用程序中创建自定义元素,然后将其替换为我们的元素,但是当我希望整个应用程序都带有延迟加载模块时,它将无法像在运行时不标识模块那样工作.自定义元素.

I know the custom elements can be created in separate application with app-root and replace it with our element but when I want whole application with lazy load modules, it will not work like not identify modules on run time when referring as a custom element.

要了解什么是自定义元素,请参考以下链接: https://angular.io/guide/elements

To understand what is custom element please refer below link: https://angular.io/guide/elements

推荐答案

要加载子级,请在路径路径中使用loadChildren并在RouterModule.forRoot(routes)

For loading children, use loadChildren in route path and RouterModule.forRoot(routes)

路线前.

 { path: 'upload', loadChildren: './upload-image/upload-image.module#UploadImageModule' }

这篇关于我可以使用延迟加载模块创建应用程序的自定义元素吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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