Angular 2 ng-bootstrap close Modal

前端 未结 3 920
无人及你
无人及你 2020-12-09 17:50

I am trying to close the modal that was presented to me through the open(content) function as shown in the example in the Documentation of ng-boostrap. In the website, it me

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-09 18:37

    Answer can be found here. ng-bootstrap website is missing lots of information unfortunately Cannot close ng-bootstrap Modal

    Inside the component class

      private modalRef: NgbModalRef;
    
      // Modal
      open(content) {
        this.modalRef = this.modalService.open(content);
        this.modalRef.result.then((result) => {
          this.closeResult = `Closed with: ${result}`;
        }, (reason) => {
          this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
        });
      }
    
      onSave() {
        this.modalRef.close();
      }
    

提交回复
热议问题