These are the basic operations you can do with $http:
$http.get(): Accepts aURL and optionalconfigobject. Performs an HTTPGETrequest.$http.head(): Accepts a URL and optionalconfigobject. Performs an HTTPHEADrequest.$http.post(): Accepts a URL, data object, and optionalconfigobject. Performs an HTTPPOSTrequest.$http.put(): Accepts a URL, data object, and optionalconfigobject. Performs an HTTPPUTrequest.$http.delete(): Accepts a URL and optionalconfigobject. Performs an HTTPDELETErequest.$http.jsonp(): Accepts a URL and optionalconfigobject. The callback name should be the stringJSON_CALLBACK.$http.patch(): Accepts a URL, data object, and optionalconfigobject. Performs an HTTPPUTrequest.
Example of calling the get() method:
$http({
method: 'GET',
url: 'http://localhost:8000'
});
$http.get('http://localhost:8000');You can easily chain promises to handle success or error returns from the server:
$http.get('http://localhost:8000')
.success(function(data){
$scope.contacts = data;
})
.error(function(){
window.alert('There was an error!');
});Example of a post:
$http.post('http://localhost:8000', {
name: 'Declan Proud',
email: 'declan@example.com',
...
});