No component factory found error for a modal component


#1

I’m trying to use a component as modal in the App and i keep getting this error:

No component factory found for ContactMessageComponent

I declared the component in the module and added it to the entryComponent as follows:

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { ContactPage } from './contact';
import { ContactMessageComponent } from "./components/contact-message-modal";
import { ComponentsModule } from '../../components/components.module';

@NgModule({
  declarations: [
    ContactMessageComponent,
    ContactPage
  ],
  imports: [
    ComponentsModule,
    IonicPageModule.forChild(ContactPage),
  ],
  exports: [
    ContactMessageComponent
  ],
  entryComponents: [
    ContactMessageComponent
  ]
})
export class ContactPageModule {}

And i’m calling the modal in the ContactPage as follows:

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, ModalController } from 'ionic-angular';
import { LangEs } from '../../lang/lang.es';

import { ContactMessageComponent } from "./components/contact-message-modal";

@IonicPage()
@Component({
  selector: 'page-contact',
  templateUrl: 'contact.html',
})
export class ContactPage {
  private contactMessageModalInstance: any;

  constructor(
    public navCtrl: NavController, 
    public navParams: NavParams,
    private modalCtrl: ModalController,
    private languages: LangEs) {
  }

  public ngOnInit(): void {
    this.contactMessageModalInstance = this.modalCtrl.create(ContactMessageComponent);
  }

  public openContactMessageModal(): void {
    this.contactMessageModalInstance.present();
  }
}

Do you know what could be happening? Thanks for any response or idea


#2

This article help me