angular - Angular 6 中的错误:找不到 PostJobComponent 的组件工厂。你把它添加到@NgModule.entryComponents 了吗?
问题描述
我正在使用 MEAN 堆栈框架创建一个 Web 应用程序,Angular 版本是 6。我正在使用 ngx-admin 模板。我在 pages 文件夹中创建了一个名为“postJob”的组件。
例如:src->app->pages->post-job。
我也将新创建的 post job 组件添加到 pages 模块的 entryComponents 中。
页。模块.ts
const PAGES_COMPONENTS = [
PagesComponent,
];
@NgModule({
imports: [
PagesRoutingModule,
ThemeModule,
DashboardModule,
MiscellaneousModule,
],
declarations: [
...PAGES_COMPONENTS,
PostJobComponent,
],
entryComponents: [PostJobComponent]
})
export class PagesModule {
constructor(private injector: Injector){
console.log("This is pages module");
const customPostJob= createCustomElement(PostJobComponent, {injector});
customElements.define('post-job',customPostJob);
}
ngDoBootstrap(){}
}
但是在调试应用程序时会出现以下错误。
未找到 PostJobComponent 的组件工厂。你把它添加到@NgModule.entryComponents 了吗?
这是我的项目目录的结构。
我在互联网上尝试了几种与我的问题相关的解决方案。但它没有用。谁能帮我理解我的错误?
解决方案
看来您有超过 1 个模块
将此组件放在根模块中或将该模块导入到 appModule
推荐阅读
- c# - Microsoft Bot Framework 通过键入“Reset”来重置 Bot 在 Azure 中不起作用
- python - 带有分组复选框的 Django 表单
- git - 如何将 git 的 STDERR 输出通过管道传输到 findstr 以获得实际结果?
- python - 具有多个 GPU 的 MNIST CNN 上的低准确度
- angular - Manifest.json 未复制到 dist
- java - JAR 资源输入流未读取请求的大小
- javascript - Sweetalert2 电子邮件验证不起作用
- c++ - ASLR 和 VirtualAlloc 的奇怪行为
- angular-material - 如何动态更新嵌套的mat-tree
- javascript - setState 在 for 循环中设置相同的对象