angular - NgbModal 未从另一个组件中包含的组件打开模式

标签 angular ng-bootstrap

我正在使用Anuglar 6

我有两个组件帐户个人资料帐户组件已添加到应用程序组件中。

我想通过点击帐户组件中的按钮来打开个人资料组件

但这给了我一个错误

Error: No component factory found for NgbModalBackdrop. Did you add it to @NgModule.entryComponents?

应用程序模块看起来像

@NgModule({
  imports:      [ BrowserModule, FormsModule ],
  declarations: [ AppComponent, HelloComponent, AccountComponent, ProfileComponent ],
  entryComponents: [
    ProfileComponent
  ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

这是工作示例:https://stackblitz.com/edit/angular-uwobqm

最佳答案

这是一个很大的模糊猜测,但您可能需要像这样在 app.module.ts 中导入 NgbModule

import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

@NgModule({
  imports: [
    NgbModule.forRoot()
  ]
})

这应该可以解决您遇到的错误。

关于angular - NgbModal 未从另一个组件中包含的组件打开模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53300365/

相关文章:

angular - 带数据循环的折叠区域

angular - 如何在 Angularjs2 (2.0.1) 中更快地加载 Observable rxjs/Rx lib

javascript - 更新数组模型取消选择迭代的 <Input> 元素

angular - ionic 4 错误 "Uncaught (in promise): Error: Cannot find module ' ../home/home.module/'

Angular2 ng-bootstrap : Reuse modal template with different data

javascript - ngbNav 中的非事件选项卡验证

angular - Angular 4 中的 Bootstrap 轮播错误

Angular 2 - Firebase Storage -putString() 方法支持元数据吗?

angular - Angular 2+中带有参数的单元测试指令

angularjs - Ng-bootstrap 导入错误 Angular 2