We have the following validation function:
var result = scope.CurrentUser.Surname.length > 0;
var d = $q.defer();
if (result) {
apiService.UniqueEmailCheck(scope.CurrentUser.PersonId, scope.CurrentUser.Email)
.success(function (response) {
if (response) {
apiService.GetSelectetExistent(scope.CurrentUser.FirstName, scope.CurrentUser.Surname, scope.CurrentUser.DOB)
.success(function (response) {
$scope.SelectExistent = response;
d.resolve($scope.SelectExistent.length > 0);
});
}
else {
d.resolve(false);
}
})
}
else
d.resolve(false);
return d.promise;
If the incoming result is true
, we have to check one or two async conditions.
It works as expected but we are not sure if we can do better. Any suggestions?