NgbModal无法从另一个组件中包含的组件打开模态 [英] NgbModal not opening modal from component included in another component

查看:80
本文介绍了NgbModal无法从另一个组件中包含的组件打开模态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Anuglar 6

我有两个组成部分accountprofile. 帐户组件已添加到应用组件.

I have two components account and profile. account component is added to the app-component.

我想通过点击帐户组件中的按钮来打开配置文件组件.

I want to open up profile-component on click of a button from account-component.

但这给我一个错误

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

This is a big of a vague guess but you probably need to import the NgbModule like so in your app.module.ts

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

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

那应该可以解决您遇到的错误.

That should then fix the error you're running into.

这篇关于NgbModal无法从另一个组件中包含的组件打开模态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆