Ionic 4 Popover 实现错误:找不到 ProfileComponent 的组件工厂

vin*_*svl 1 ionic-framework angular ionic4

我正在尝试在 ionic 4 中实现 popover 并且它为我显示了这个错误,我已经为 popover 创建了一个独特的组件并且我正在页面上实现,所以我点击按钮来创建它给这个的组件错误。

我正在使用延迟加载并将模块导入文件,我做错了什么?

ERROR Error: "Uncaught (in promise): Error: No component factory found for ProfileComponent. Did you add it to @NgModule.entryComponents?
Run Code Online (Sandbox Code Playgroud)

弹出模块

ERROR Error: "Uncaught (in promise): Error: No component factory found for ProfileComponent. Did you add it to @NgModule.entryComponents?
Run Code Online (Sandbox Code Playgroud)

页面模块:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ProfileComponent } from './profile.component';

@NgModule({
  declarations: [ProfileComponent],
  imports: [
    CommonModule,
  ],
  entryComponents: [ProfileComponent],
})
export class ProfileModule { }
Run Code Online (Sandbox Code Playgroud)

用于创建弹出框的 Page.ts 方法:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { ProfilePage } from './profile.page';
import { ValidationSummaryComponent } from '../../../components/validation-summary/validation-summary.component';
import { ProfileComponent } from '../../../components/popovers/profile/profile.component';
import { IonicSelectableModule } from 'ionic-selectable';

const routes: Routes = [
  {
    path: '',
    component: ProfilePage
  }
];

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    ReactiveFormsModule,
    IonicSelectableModule,
    RouterModule.forChild(routes)
  ],
  declarations: [
    ProfileComponent,
    ProfilePage, 
    ValidationSummaryComponent, 
  ]
})
export class ProfilePageModule {}
Run Code Online (Sandbox Code Playgroud)

Aug*_*n R 5

如果你从Page.ts创建你的组件,你应该在PageModule 中将你的组件声明为入口组件:

declarations: [
    ...,
    ProfileComponent,
],
entryComponents: [ProfileComponent]
Run Code Online (Sandbox Code Playgroud)

[更新 6/11/2020]

使用 Angular 9,entryComponents将不再需要。查看此链接了解更多信息