ngx-bootstrap Modal Component not found even after adding to entry component

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


ngx-bootstrap Modal Component not found even after adding to entry component



Recently I have converted an ASPNETCORE 2.0 angular app to ASPNETCORE 2.1 angular app (later one uses angular/cli app). In the previous version I had some Modal Components built with ngx-bootstrap which were working correctly. But after conversion those components stopped working and started throwing this error -


ASPNETCORE 2.0


ASPNETCORE 2.1


angular/cli



No component factory found for {component}. Did you add it to @NgModule.entryComponents?



I have added following to my app.module.ts file -


@NgModule({
imports: [
ModalModule.forRoot(),
MySubModule
],
entryComponents: [
MyModalComponent
]
})



In my MySubModule -


MySubModule


@NgModule({
declarations: [
MyModalComponent
],
imports: [
ModalModule.forRoot()
]
exports: [
MyModalComponent
]
})



Even though I have defined my entry component it's throwing this error. Can anyone suggest any solution?





imports: [ ModalModule.forRoot() ], add to your MySubModule.
– fateme fazli
18 mins ago




imports: [ ModalModule.forRoot() ],





yes i have tried that. still not working. update question accordingly
– th1rdey3
17 mins ago







you are using modal in your MyModalComponent and you use MySubModule as module for it, so you should add import { ModalModule } from 'ngx-bootstrap/modal'; // or import { ModalModule } from 'ngx-bootstrap'; @NgModule({ imports: [ModalModule.forRoot(),...] }) to your MySubModule and declare your MySubModule in app.module.ts.
– fateme fazli
14 mins ago


import { ModalModule } from 'ngx-bootstrap/modal'; // or import { ModalModule } from 'ngx-bootstrap'; @NgModule({ imports: [ModalModule.forRoot(),...] })




1 Answer
1



you are using modal in your MyModalComponent and you use MySubModule as module for it, so you should add import ModalModule to your MySubModule and declare your MySubModule in app.module.ts.



In MySubModule:


import { ModalModule } from 'ngx-bootstrap/modal';

@NgModule({
declarations: [
MyModalComponent
],
imports: [
ModalModule.forRoot()
]
exports: [
MyModalComponent
]
})
export class MySubModule { }



in your app.module.ts:


@NgModule({
imports: [
MySubModule
]
})

export class AppModule { }



and its better to use ngbootstrap modal





this is just one example, i have other modal components which are directly declared in AppModule
– th1rdey3
3 mins ago





it's ok, you need to just import ModalModule to which module your component is using.
– fateme fazli
1 min ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results