In my controller with the help of service i'm sending some qr-data to users so:
$scope.sendtoList = function () {
$scope.qrStatus = false;
angular.forEach($scope.users, function (item) {
if (item.Selected){
inviteService.sendQR(item.Emails.main, $scope.company.Id).then(function(response) {
$scope.qrStatus = true;
},
function(err) {
$scope.qrStatus = false;
});
}
});
if ($scope.qrStatus){
$window.alert('QR-code has been sended successfully.');
}
else{
$window.alert('Warning! QR-code has not been sended successfully.');
}
}
and i see some strange behaviour: it always show warning alert, even if method is done succesfully - i think it is of promisses. But how could i show window in my case only after servise promisse is returned?