一旦我的保存功能成功?
如何关闭ng-bootstrap模态?这是我到目前为止所拥有的:
save(form, activeModal) {
this.goalsService.createNewGoal(this.team_id, form.value, this.date_created, this.date_modified)
.subscribe(
() => {
form.reset();
activeModal.dismiss('Successfully created Goal');
},
err => alert(`error creating goal ${err}`)
);
}
在使用NgbModal
服务打开模式时,它将返回NgbModalRef
实例。
使用返回的实例我们可以关闭或解散模式。
loginModel : NgbModalRef;
constructor(private modalService:NgbModal) {}
onOpen(){
this.loginModel = this.modalService.open(content);
}
onSave(){
.
.
.
(success)=>{
this.loginModel.close();
}
}
事实证明这是一个非常简单的修复程序。我要做的就是将activeModal.dismiss('Successfully created Goal');
更改为this.activeModal.dismiss('Successfully created Goal');