我正在尝试在ionic 4中实现该弹出框,并且正在向我显示此错误,我为该弹出框创建了一个唯一的组件,并且正在页面上实现,因此我单击该按钮以创建该组件它给出了这个错误。
我正在使用延迟加载并将模块导入文件中,这是怎么做的?
ERROR Error: "Uncaught (in promise): Error: No component factory found for ProfileComponent. Did you add it to @NgModule.entryComponents?
PopoverModule
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 { }
PageModule:
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 {}
用于创建弹出框的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();
}
答案 0 :(得分:1)
如果从 Page.ts 创建组件,则应在 PageModule 中将组件声明为输入组件:
_timernew = new System.Timers.Timer(10000)
{
AutoReset = false
};
_timernew .Elapsed += (sender, e) => { DoSomething };
_timernew .Enabled = true;