Ngbootstrap不显示“模态”窗口

时间:2019-02-23 10:14:43

标签: angular typescript ng-bootstrap

我在Angular中遇到问题。当我要创建像这样的模式窗口时(https://stackblitz.com/angular/odaogjmkqod?file=app%2Fmodal-basic.ts)。它创建了它,但没有显示它。

Image uploaded

constructor(
    private modalService: NgbModal
  ) {}

closeResult: string;


  open(content) {
    this.modalService.open(content, {ariaLabelledBy: 'modal-basic-title'}).result.then((result) => {
      this.closeResult = `Closed with: ${result}`;
    }, (reason) => {
      this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
    });
  }

  private getDismissReason(reason: any): string {
    if (reason === ModalDismissReasons.ESC) {
      return 'by pressing ESC';
    } else if (reason === ModalDismissReasons.BACKDROP_CLICK) {
      return 'by clicking on a backdrop';
    } else {
      return  `with: ${reason}`;
    }
  }

这是我的伴侣,从中我将打开模态窗口!这是我的app.module.ts

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    NgbModule,
    FormsModule,
    InvoiceDetailModule,
    InvoiceModule,
    GeneralModule,
    ApiModule,
    OverviewModule,
    NgbModalModule,
    NgbCollapseModule,
    ReactiveFormsModule
  ],
  providers: [{
    provide: ApiConfiguration,
    useClass: EnvironmentApiConfiguration
  }],
  bootstrap: [AppComponent],
  entryComponents: [InvoicePositionComponent]
})

我在做什么错了?

PS:对不起,我的英语不好!

0 个答案:

没有答案