从组件打开Angular Bootstrap模态(Open Angular Bootstrap modal from component)
我正在尝试使用角引导来设置一个简单的模态。 但我跑到这个错误:
"ERROR Error: No component factory found for ModalContentComponent. Did you add it to @NgModule.entryComponents? at noComponentFactoryError"我已经导入了模块,但仍然无法正常工作。 我已经从文档HERE开始,并在这里看到了这个StackOverflow问题。
这是我的app.module:
import { FormPoster } from './services/form-poster.service'; import { DatepickerModule } from 'ngx-bootstrap/datepicker'; import { ButtonsModule } from 'ngx-bootstrap/buttons'; import { RatingModule } from 'ngx-bootstrap/rating'; import { AddGameComponent } from './add-game/add-game.component'; import { ModalModule } from 'ngx-bootstrap'; @NgModule({ declarations: [ AppComponent, EmployeeComponent, EmployeeTitlePipe, EmployeeListComponent, EmployeeCountComponent, HomeComponentComponent, PageNotFoundComponent, AddEmployeeComponent, AddGameComponent, ], imports: [ BrowserModule, BrowserAnimationsModule, FormsModule, HttpModule, ButtonsModule.forRoot(), RatingModule.forRoot(), ModalModule.forRoot(), DatepickerModule.forRoot(), RouterModule.forRoot(appRoutes) ], providers: [EmployeeService, FormPoster], bootstrap: [AppComponent] }) export class AppModule { }I'm trying to set up a simple modal using angular bootstrap. But I'm running to this error :
"ERROR Error: No component factory found for ModalContentComponent. Did you add it to @NgModule.entryComponents? at noComponentFactoryError"I've imported the module but still unable to get this working. I've started with the documentation HERE and also looked at this StackOverflow question HERE.
Here is my app.module :
import { FormPoster } from './services/form-poster.service'; import { DatepickerModule } from 'ngx-bootstrap/datepicker'; import { ButtonsModule } from 'ngx-bootstrap/buttons'; import { RatingModule } from 'ngx-bootstrap/rating'; import { AddGameComponent } from './add-game/add-game.component'; import { ModalModule } from 'ngx-bootstrap'; @NgModule({ declarations: [ AppComponent, EmployeeComponent, EmployeeTitlePipe, EmployeeListComponent, EmployeeCountComponent, HomeComponentComponent, PageNotFoundComponent, AddEmployeeComponent, AddGameComponent, ], imports: [ BrowserModule, BrowserAnimationsModule, FormsModule, HttpModule, ButtonsModule.forRoot(), RatingModule.forRoot(), ModalModule.forRoot(), DatepickerModule.forRoot(), RouterModule.forRoot(appRoutes) ], providers: [EmployeeService, FormPoster], bootstrap: [AppComponent] }) export class AppModule { }最满意答案
在模块文件中的entryComponent中添加ModalContentComponent 。
如下所示:
entryComponents: [ ModalContentComponent ]Add ModalContentComponent inside entryComponent in your module file.
Like following :
entryComponents: [ ModalContentComponent ]更多推荐
发布评论