No component factory found for Tab2Page. Did you add it to @NgModule.entryComponents?

今天用 ionic 弹出模态框时报错: No component factory found for Tab2Page. Did you add it to @NgModule.entryComponents?

这主要是因为 ionic 使用 angular 的路由懒加载方式,即用 loadChildren,如果用 component 方式则不会用这种问题。

解决方法:

@NgModule({
  imports: [
    IonicModule,
  ],
  declarations: [OrdersComponent, CustomersComponent],
  entryComponents: [CustomersComponent]
})
export class OrdersModule { }

首先必须引入 IonicModule ,然后在 entryComponents 和 declarations 中分别添加:CustomersComponent

如果模态框被很多次调用,则可以将 CustomersComponent 配置放到 app.module.ts 中

你可能感兴趣的:(B-JavaScript,entryComponents,NgModule,No,component,ionic)