本文介绍了如何在另一个ng-module上导入/使用惰性加载模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个ng-module

I have two ng-module

  1. 仪表板
  2. 重复订单列表

我已经通过延迟加载加载了重复订单.

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.

  1. AppModule导入MainModule(类似于您的DashboardModule).
  2. ReapeatOrder模块是延迟加载的,可以从MainModule
  3. 导航到
  4. 两个模块均导入具有共享组件的共享模块.
  5. MainModuleReapeatOrder都在其模板中使用共享组件.
  1. AppModule imports the MainModule (similar to your DashboardModule).
  2. ReapeatOrder module is lazy-loaded and can be navigated to from the MainModule
  3. Both Modules import a shared module, with shared components.
  4. Both MainModule and ReapeatOrderuse the shared components in their templates.

这篇关于如何在另一个ng-module上导入/使用惰性加载模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 15:00