【问题标题】:No component factory found for... Opening a Modal没有找到用于...的组件工厂
【发布时间】:2019-07-27 14:14:49
【问题描述】:

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

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>

这就是我的结构:

github 上的回购: https://github.com/tiagosilveiraa/PManager

【问题讨论】:

    标签: javascript angular typescript ionic-framework


    【解决方案1】:

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

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

    【讨论】:

    • 我试过了,但它只适用于在 app.module.ts 中的页面内导入页面
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 2017-02-15
      • 1970-01-01
      • 2019-03-13
      • 2020-03-08
      • 1970-01-01
      • 2020-06-12
      • 2019-03-02
      • 2018-11-21
      • 1970-01-01
      相关资源
      最近更新 更多