ionic中popoverController、modalController中的参数component指定的页面或组件报错

在ionic中,如果使用modalController,按官方文档的示例代码,像这样:

  //显示界面
  async showPopover() {
    const popover = await this.popoverController.create({
      component: MyComponent
    });
    await popover.present();
  }

但如果直接运行会报错:

ERROR Error: Uncaught (in promise): Error: No component factory found for ****. Did you add it to @NgModule.entryComponents?
Error: No component factory found for ****. Did you add it to @NgModule.entryComponents?

解决方法:

需要在当前页面或组件的module.ts文件中添加

import { MyComponent } from '.../../*.component';

@NgModule({
  declarations: [
    MyComponent,
    ...
  ],
  entryComponents: [
    MyComponent,
    ...
  ],
    ...
})
原文地址:https://www.cnblogs.com/johnjackson/p/13724545.html