从组件打开Angular Bootstrap模态(Open Angular Bootstrap modal from component)

编程入门 行业动态 更新时间:2024-10-27 16:36:06
组件打开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 ]

更多推荐

本文发布于:2023-08-06 13:38:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1448492.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组件   模态   Angular   component   Bootstrap

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!