I have a secondary module of the AppModule, in this case, it is called DriverModule, and within that module, I have the DriversService service added within the providers array. Within the DriversModule, I have children routes that I charge using lazy modules.
The service works well within all pages under DirverModule.
My problem is when I try to put a modal into that service that is running on all the daughter pages of DriversModule, I get this error:
ERROR Error: Uncaught (in promise): Error: No component factory found for ServiceOfferingComponent. Did you add it to @NgModule.entryComponents?
Error: No component factory found for ServiceOfferingComponent. Did you add it to @NgModule.entryComponents?
at noComponentFactoryError
Even though I already put the component inside the declarations and entryComponents arrays.
import { ServiceOfferingComponent } from './service-offering/service-offering.component';
@NgModule({
declarations: [
ServiceOfferingComponent
],
imports: [
RouterModule.forChild(routes)
],
providers: [
DriverService,
],
entryComponents: [
ServiceOfferingComponent
]
})
export class DriverModule { }
import { ServiceOfferingComponent } from './service-offering/service-offering.component';
import { ModalController } from '@ionic/angular';
@Injectable()
export class DriverService {
constructor(
public modalController: ModalController
) {
someObservable$.subscription((val:boolean) =>{
if(val) this.showServiceOfferingModal();
});
}
async showServiceOfferingModal() {
const modal = await this.modalController.create({
component: ServiceOfferingComponent,
backdropDismiss: false
});
await modal.present();
}
}
My assumption is that if the service works well within all the daughter routes of DriversModule I can present the modal on the current daughter page, no matter on which daughter page of the DriversModule I am browsing as long as the service is available. But apparently, that assumption is incorrect.
Do you know any technique to put a modal into a service and when a condition arises, present the modal on the page that the user is browsing, regardless of which page it is as long as it is the daughter page of the DriversModule?