找不到用于...的组件工厂

时间:2019-03-06 01:39:33

标签: javascript angular typescript ionic-framework

我有一个页面应该加载到模式中,该页面是其他页面的子页面(我认为这没关系,但是...)关键是当我尝试创建模式时会收到错误消息下面

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

但是,当我进入AppModule将页面放入entryComponents时,出现此错误:

Component TarefasDetalhePage is not part of any NgModule or the module has not been imported into your module.

模态的调用在我的HomePage.ts上:

  async showModal(id){
    const modal = await this.modalController.create({
     component: TarefasDetalhePage,
     componentProps:{
       custom_id: id
     }
    });
    modal.present();
  }

这是标记:

    <ion-list *ngIf="interna === true" >
    <ion-item (click)="showModal(tarefa.id)"   routerDirection="forward" detail *ngFor="let tarefa of tarefasInternas" class="in-list item ion-focusable item-label hydrated">
      <ion-label>
        <h2>#{{tarefa.numero}} - {{tarefa.descricao}}</h2>
        <h3>{{tarefa.inicio}} - {{tarefa.fim}}</h3>
        <p>{{tarefa.comentarios}}</p>
      </ion-label>
    </ion-item>
  </ion-list>

那是我的结构:

enter image description here

在github上的仓库: https://github.com/tiagosilveiraa/PManager

2 个答案:

答案 0 :(得分:1)

要在模式中打开component,必须在component中将app.module.js添加为entryComponent

您的error消息表明了这一点。

答案 1 :(得分:0)

您必须在NgModule中编辑tarefas.module.ts。 请根据需要添加其余的内容。

@NgModule({
    imports: [
        MatDialogModule
    ],
    declarations: [
        ComponentName
    ],
    providers: [
        { provide: MAT_DIALOG_DEFAULT_OPTIONS, useValue: { hasBackdrop: true, closeOnNavigation: true } }
    ],
    entryComponents: [
        ComponentName
    ],
    exports: [
        ComponentName
    ],
})

export class Module {

}