2016-11-24 6 views
0

保存機能が正常に終了したら、どのようにng-bootstrapモーダルを閉じることができますか?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}`) 
    ); 

    } 
+1

。最も重要な部分は、モーダル内の 'save'メソッドですか?それとも外? –

+0

「閉じる」方法を有することができる –

答えて

0

は、それは非常に簡単な修正だったが判明します。私が行うために必要なすべてがNgbModalサービスを使用してモーダルを開く時にthis.activeModal.dismiss('Successfully created Goal');

0

activeModal.dismiss('Successfully created Goal');を変更し、それがNgbModalRefインスタンスを返します。

戻されたインスタンスを使用して、モーダルを閉じるか、閉じることができます。

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

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

onSave(){ 
. 
. 
. 
    (success)=>{ 
     this.loginModel.close(); 
    } 
} 
activeModalは、あなたが何をしようとすると動作していないものをクリアしていない、それを提供してきましたスニペットからのようなあなたは(理想的にplunkerに)より多くのコードが表示されるはずです
関連する問題