问题描述
我有两个ng-module
I have two ng-module
- 仪表板
- 重复订单列表
我已经通过延迟加载加载了重复订单.
I had loaded Repeat order through the lazy load.
现在我想在仪表板内使用重复订单作为html
Now I want to use Repeat order, inside dashboard as html
<app-repeatorderlist></app-repeatorderlist>
如果我也这样做,则会抛出错误
If I am doing same it is throwing me an error
"app-repeatorderlist"不是已知元素:1.如果"app-repeatorderlist"是一个Angular组件,则请验证它是否是此模块的一部分.2.如果'app-repeatorderlist'是Web组件,则将'CUSTOM_ELEMENTS_SCHEMA'添加到该组件的'@ NgModule.schemas'中
'app-repeatorderlist' is not a known element:1. If 'app-repeatorderlist' is an Angular component, then verify that it is part of this module.2. If 'app-repeatorderlist' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to
如果我在app.module上添加它的引用,则会引发错误
And if I am adding it's reference on app.module then it's throwing error
类型RepeatorderlistComponent是2个模块的声明的一部分:AppModule和repeatorderModule!请考虑将RepeatorderlistComponent移至导入AppModule和repeatorderModule的更高模块.您还可以创建一个新的NgModule,该NgModule可以导出并包含RepeatorderlistComponent,然后在AppModule和repeatorderModule中导入该NgModule.错误:类型RepeatorderlistComponent是2个模块的声明的一部分:AppModule和repeatorderModule!请考虑将RepeatorderlistComponent移至导入AppModule和repeatorderModule的更高模块.您还可以创建一个新的NgModule,该NgModule导出并包含RepeatorderlistComponent,然后将该NgModule导入AppModule和repeatorderModul
Type RepeatorderlistComponent is part of the declarations of 2 modules: AppModule and repeatorderModule! Please consider moving RepeatorderlistComponent to a higher module that imports AppModule and repeatorderModule. You can also create a new NgModule that exports and includes RepeatorderlistComponent then import that NgModule in AppModule and repeatorderModule.Error: Type RepeatorderlistComponent is part of the declarations of 2 modules: AppModule and repeatorderModule! Please consider moving RepeatorderlistComponent to a higher module that imports AppModule and repeatorderModule. You can also create a new NgModule that exports and includes RepeatorderlistComponent then import that NgModule in AppModule and repeatorderModul
我可以理解,我必须创建一个新的模块(更高版本),但是如何在同一模块上进行任何引导
I can understand I have to create a new module(higher) but how can any body guide on same
推荐答案
这是我刚刚制作的一个工作示例,向您展示了它的设置方式.
Here is a working example I just made to show you how it is setup.
-
AppModule
导入MainModule
(类似于您的DashboardModule)
. -
ReapeatOrder
模块是延迟加载的,可以从MainModule
导航到 - 两个模块均导入具有共享组件的共享模块.
-
MainModule
和ReapeatOrder
都在其模板中使用共享组件.
AppModule
imports theMainModule
(similar to yourDashboardModule)
.ReapeatOrder
module is lazy-loaded and can be navigated to from theMainModule
- Both Modules import a shared module, with shared components.
- Both
MainModule
andReapeatOrder
use the shared components in their templates.
这篇关于如何在另一个ng-module上导入/使用惰性加载模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!