I used entryComponents in a module which was loaded into AppModule. It works fine.
But when I use entryComponents in a lazyloaded Child Modules, I get the error message - 'No component factory found for LoadDialogComponent. Did you add it to @NgModule.entryComponents?'
I'm using [email protected], [email protected].
Here is my code
AppModule:
import { NgModule, NO_ERRORS_SCHEMA, ModuleWithProviders} from '@angular/core';
import { NativeScriptModule } from 'nativescript-angular/nativescript.module';
import { NativeScriptRouterModule } from 'nativescript-angular/router';
import { AppComponent } from './app.component';
import { Routes } from '@angular/router';
const appRoutes: Routes = [
{ path: 'user', loadChildren: '~/app/user/user.module#UserModule'},
]
@NgModule({
imports: [
NativeScriptRouterModule,
NativeScriptModule,
NativeScriptRouterModule.forRoot(appRoutes, {
useHash : true,
}),
],
declarations: [
AppComponent,
],
providers: [
],
exports: [
],
entryComponents:[
],
bootstrap: [AppComponent],
schemas: [NO_ERRORS_SCHEMA]
})
export class AppModule {
constructor(){}
static forChild(): ModuleWithProviders {
return {
ngModule: AppModule,
providers: [
]
};
}
}
UserModule
import { NgModule, ModuleWithProviders, NO_ERRORS_SCHEMA , NgModuleFactoryLoader} from '@angular/core';
import { UserFreeTrialModalComponent } from './components/user-registraion/user-registraion.component.tns';
import { ModalDialogService } from 'nativescript-angular/modal-dialog';
@NgModule({
imports: [
NativeScriptCommonModule,
NativeScriptRouterModule,
],
declarations: [
UserFreeTrialModalComponent
],
providers:[
ModalDialogService
],
schemas:[
NO_ERRORS_SCHEMA
],
exports:[
UserFreeTrialModalComponent
],
entryComponents:[
UserFreeTrialModalComponent
]
})
export class UserModule {
constructor( ) {
}
static forChild(): ModuleWithProviders {
return {
ngModule: UserModule,
providers: [
]
};
}
}
Please let me know if you need more details
@chaitanyamolli1310 we have the very same scenario in your test app here and it is working as expected.
I've noticed that you are importing the ModalDialogSertice but this is automatically provided but the NativeScriptModule. Instead, you should directly inject the service in your component. Please remove the following from your UserModule
providers:[
ModalDialogService
],
Thanks @NickIliev
I checked my code again. Indeed, entryComponents is working fine.
The problem was that I've only tns version of the modal component. I created a dummy web version now . All seem to be working fine.
I've removed ModalDialogService from all modules and only included that in the components, as you suggested.
Thanks for your quick response. Much appreciated :+1:
Most helpful comment
Thanks @NickIliev
I checked my code again. Indeed, entryComponents is working fine.
The problem was that I've only tns version of the modal component. I created a dummy web version now . All seem to be working fine.
I've removed ModalDialogService from all modules and only included that in the components, as you suggested.
Thanks for your quick response. Much appreciated :+1: