首页 > 解决方案 > Angular: Close a MatDialog

问题描述

I am opening a loading MatDialog when I make a HTTP request. However when I try to close it in the subscription of the call it doesnt close it.

What am I doing wrong?

      saveListOfSteps(isFormValid: boolean): void{

    if(isFormValid== false){
      alert("You have not filled out all fields in the form! Fix that first");
    }else{
      // show a loading dialog
      let dialogRefLoading = this.dialog.open(PopupComponent, {
        width: '250px',
        data: {
          data: ["Loading..."],
          showCloseButton: false},
      },    
      );
     dialogRefLoading.close;
     this.SelfServiceDetailsService.saveListOfSteps(this.validationSteps)
     .subscribe(response=>{
      dialogRefLoading.close;
       this.showSaveResultsDialog(response.body),
     error => alert("An error occured")});
    }

  }

标签: angulartypescript

解决方案


close is function so you have to call it like

dialogRefLoading.close();

instead of

 dialogRefLoading.close;

推荐阅读