In this section, we shall learn server call related services in AngularJS that is used to send asynchrnous request to server and receive response.
In AngularJS, communication to the server is done using $http service. As per official website of AngularJS, "the $http service is a core Angular service that facilitates communication with the remote HTTP servers via the browser's XMLHttpRequest object or via JSONP".
The syntax of $http service looks like below
$http({ method: 'METHOD-NAME', url: 'URL' })
.then(
function successCallback(response) {
// this will be called asynchronously after success
},
function errorCallback(response) {
// called asynchronously if an error occurs
}
);
There are short hand methods for almost all Form methods, that are explained in below posts.