组件的开放式角度引导模态

问题描述 投票:0回答:3

我正在尝试使用角度引导程序建立一个简单的模态。但是我遇到了这个错误:

 "ERROR Error: No component factory found for ModalContentComponent. Did you add it to @NgModule.entryComponents?
    at noComponentFactoryError"

我已经导入了模块,但仍然无法正常工作。我从文档HERE开始,还研究了这个StackOverflow问题HERE

这是我的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 { }
angular bootstrap-modal angular-module
3个回答
1
投票

在模块文件的ModalContentComponent内添加entryComponent

喜欢以下内容:

entryComponents: [
    ModalContentComponent
]

0
投票

您应该将组件添加到@ NgModuleentryComponents

步骤1:将组件导入app.module.ts

import { CatalogDetailsComponent, ModalContentComponent } from './catalog-details/catalog-details.component'

步骤2:将导入的模块添加到@ NgModule

@NgModule({
  declarations: [
    AppComponent,
    ModalContentComponent 
  ],

步骤3:在@ NgModule下添加entryComponents,如果还不存在,则在其中添加导入的组件

  entryComponents: [
    ModalContentComponent
  ],

此修复程序对我有用。如果也对您有用,请给一个赞。.谢谢


-1
投票

将组件作为entryComponentsdeclarations中的组件添加到模块中。

© www.soinside.com 2019 - 2024. All rights reserved.