I am facing an issue with my Angular function where I need to wait for a response from the user. I believe that using "subscribe()" might help, but I am unclear on how and when to use it properly. My current call looks like this:
theAnswer:boolean = await showConfirmDialog("Confirm Changes!", "Are you sure you want to cancel your changes?);
async showConfirmDialog(title: string, message: string) {
var answer: boolean = false;
this.dialog
.confirmDialog({
title: title,
message: message,
confirmCaption: 'Yes',
cancelCaption: 'No'
})
.subscribe((yes) => {
if (yes) {
answer = true;
}
else {
answer = false;
};
});
console.log('selected answer ' + answer)
return answer;
}
}