1

保存功能成功后,如何关闭 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}`)
      );

  }
4

2 回答 2

2

使用NgbModal服务打开modal时,会返回NgbModalRefinstance。

使用返回的实例,我们可以关闭或关闭模式。

loginModel : NgbModalRef;
constructor(private modalService:NgbModal) {}

onOpen(){
     this.loginModel =  this.modalService.open(content);
}

onSave(){
.
.
.
   (success)=>{
       this.loginModel.close();
   }
}
于 2018-02-09T12:20:20.657 回答
0

原来这是一个非常简单的修复。我需要做的就是activeModal.dismiss('Successfully created Goal');改变this.activeModal.dismiss('Successfully created Goal');

于 2016-12-12T03:38:54.687 回答