I’m implementing lazy loading in my ionic 3/angular5 app in order to boost performance. But I’m unable to open a modal using it and it drives me crazy. I have a page (Journal in red) where I load messages and display them (message-item in green). When the user click on it, it open the full message (MessageModal in blue) on a modal like below.
I created 3 separate modules for each of them. But I keep getting the following error after a tap on the button OPEN MESSAGE although I added the MessageModal to the message-item module :
Uncaught (in promise) : Error : No component factory found for
MessageModal. Did you add it to @NgModule.entryComponents
So I tried to add the ModalMessage to entryComponents to each modules/components but it still doesn’t work and I’m really stuck.
JournalModule should need to import the MessageModule and MessageModalModule and MessageModule should add MessageModal to its entryComponents. Please find the code below :
journal.module.ts
@NgModule({
declarations: [ JournalPage ],
imports: [
MessageModalModule,
MessageModule,
IonicPageModule.forChild(JournalPage)
],
providers: [JournalService],
exports: [JournalPage],
entryComponents :[MessageModal]
})
export class JournalPageModule {}
Piece of journal.html
<ion-list *ngIf="messages.length !=0 && messageLoaded == true">
<message-item *ngFor="let message of messages" [message]="message" (quizz)="handleQuizzResult($event)" (delete)="deleteMessage($event)" (isRead)="messageRead($event)" ></message-item>
</ion-list>
message.module.ts
@NgModule({
declarations: [ MessageItem ],
entryComponents : [MessageModal],
imports: [ IonicPageModule.forChild(MessageItem)],
exports : [MessageItem]
})
export class MessageModule {}
Piece of message.ts
@IonicPage()
@Component({
selector: 'message-item',
templateUrl: './message.html',
entryComponents : [MessageModal]
})
...
let modal = this.modalCtrl.create( MessageModal, { message : this.message });
message-modal.module.ts
@NgModule({
declarations: [ MessageModal ],
imports: [ IonicPageModule.forChild(MessageModal)],
exports : [MessageModal]
})
export class MessageModalModule {}
I don’t know where am i wrong… Any advices/docs appreciated !