In my view, I need to do some extra "form validation" with my backend (called with $http). To abort or trigger the form sending, I need to wait for the promise returned by $http to finish.
$('#myForm').submit(function() {
...
$http(...).success(function(data) {
if (data.condition){
//send the form by returning true
return true;
} else {
//stay on this page by returning false
return false;
});
//what should I return here ??
}
In general, how do we wait/block for a promise to finish, such as the one returned by the $http() function?