一、NgbActiveModal出错
'NgbActiveModal' imported by the module 'HomeModule'. Please add a @NgModule annotation
二、NgbModalRef
import { NgbModal, ModalDismissReasons, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
// open
openAddStrategy(content, index) {
const that = this;
const modal = this.modalService.open(content, { size: 'sm' });
this.mr = modal;
this.strategyName = '';
modal.result.then((result) => {
this.closeResult = `Closed with: ${result}`;
console.log('strategy');
that.addStrategy('strategy');
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
console.log(this.closeResult);
});
}
public mr: NgbModalRef;
// 关闭弹框
colseModal() {
this.mr.close();
}
参考:
https://stackoverflow.com/questions/42069118/angular2-ng-bootstrap-modal-close-in-component