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")});
}
}
close
is function so you have to call it like
dialogRefLoading.close();
instead of
dialogRefLoading.close;
You are defined dialogRefLoading
variable inside the else condition. It should be declared globally. And close()
is a function not property in Dialog
class. So you should use dialogRefLoading.close()
instead of dialogRefLoading.close
Try this below code instead of your code
saveListOfSteps(isFormValid: boolean): void {
let dialogRefLoading = null;
if (isFormValid == false) {
alert("You have not filled out all fields in the form! Fix that first");
} else {
// show a loading dialog
dialogRefLoading = this.dialog.open(PopupComponent, {
width: '250px',
data: {
data: ["Loading..."],
showCloseButton: false
},
},
);
this.SelfServiceDetailsService.saveListOfSteps(this.validationSteps)
.subscribe(response => {
dialogRefLoading.close();
this.showSaveResultsDialog(response.body),
error => alert("An error occured")
});
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.