Angular 保存时关闭ng引导模式
保存功能成功后,如何关闭ng引导模式 以下是我目前掌握的情况:Angular 保存时关闭ng引导模式,angular,ng-bootstrap,Angular,Ng Bootstrap,保存功能成功后,如何关闭ng引导模式 以下是我目前掌握的情况: save(form, activeModal) { this.goalsService.createNewGoal(this.team_id, form.value, this.date_created, this.date_modified) .subscribe( () => { form.reset(); activeModal.dismiss
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}`)
);
}
原来这是一个非常简单的修复。我所需要做的就是更改
activeModal.dismise('Successfully created Goal')
到this.activeModal.dismise('Successfully created Goal')
在使用NgbModal
服务打开modal时,它将返回NgbModalRef
实例
使用返回的实例,我们可以关闭或关闭模态
loginModel : NgbModalRef;
constructor(private modalService:NgbModal) {}
onOpen(){
this.loginModel = this.modalService.open(content);
}
onSave(){
.
.
.
(success)=>{
this.loginModel.close();
}
}
activeModal可能有一个“关闭”方法。您应该显示更多的代码(最好是在plunker中),因为您提供的代码片段不清楚您正在尝试做什么,哪些不起作用。最重要的部分-模式中的
save
方法吗?还是在它之外?