I am encountering 2 issues with the $http function in this particular code snippet.
$scope.buttonClick = function(){
// Sending input data
$.post('lib/add_contact.php', $scope.contact, function(data){
data = angular.fromJson(data);
if(!data.error){
$scope.contact = "";
console.log('success');
}else{
console.log('error');
}
});
// Following Code
console.log('Next Code');
}
The first issue I am facing is that when I try to clear a contact, it doesn't happen immediately. It only clears after I press a key into the input field. If I move
$scope.contact = "";
outside of the POST request, it works as expected.
The second problem is why the POST request is being called last. The current output of the code execution is:
Code Next
success
but I would like the output to be:
success
Code Next
Thank you for any suggestions and solutions!