I have an API call that will respond a list, and I want to show a dialog box for each error, but I want the next dialog box(es) to display after I pressed Yes for the first one. How do I handle this? because for now, It continues to the loop even if there's no selected answer yet.
I've tried the answer from this Link but it didn't worked for me.
Any other way to handle this?
timeSheetApi
.validate(clonedTimesheet)
.then(function (resp) {
var validationErrors = resp.data;
line.ErrorCount = 0;
line.WarningCount = 0;
line.Errors = "";
if (validationErrors.length > 0) {
line.ErrorCount = validationErrors.length;
validationErrors.forEach(detail,index){
let confirm = $mdDialog.confirm()
.title('')
.htmlContent(detail.Message)
.ok('Yes')
.cancel('No');
$mdDialog.show(confirm).then(function(){
//yes
//i want the loop to wait for this yes
}, function(){
//no
// and exit this loop if no was selected
});
}
line.Errors = cleanErrorMessage(line.Errors);
triggerOption(sourceColumn, prop, index, val, time_field);
return line;
}).catch(function (err) {
exceptionService.resolve(err);
});