【发布时间】:2019-08-10 07:22:57
【问题描述】:
我正在尝试在 ionic 4 中实现弹出框,它为我显示此错误,我为弹出框创建了一个独特的组件,并且正在页面上实现,所以我单击按钮来创建组件它给出了这个错误。
我正在使用延迟加载并将模块导入文件,我做错了什么?
ERROR Error: "Uncaught (in promise): Error: No component factory found for ProfileComponent. Did you add it to @NgModule.entryComponents?
弹出框模块
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 { }
页面模块:
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 {}
创建popover的Page.ts方法:
import { ProfileComponent } from '../../../components/popovers/profile/profile.component';
async openPopover(ev: any) {
const popover = await this.popoverCtrl.create({
component: ProfileComponent,
event: ev,
translucent: true
});
return await popover.present();
}
【问题讨论】:
-
能不能显示你导入PopoverModule和PageModule的地方
-
您不需要配置文件模块。删除配置文件模块。您的页面模块看起来不错。
-
我删除了配置文件模块,但错误仍然存在,我在 paginia 模块中弹出模块
标签: angular ionic-framework ionic4