1.

AngularJS $http

Answer»

AngularJS $http
We use $http as a SERVICE to read data from remote servers. From AngularJS $http we make a request to the server and returns a response. Below is the example of $http request response model.


AngularJS Http Service
METHODS
In above example we uses the .get METHOD of $http service. And .get method is a

shortcut method of $http service. Below are the example of different shortcut methods
(i).delete()
(ii).get()
(iii).head()
(iv).JSONP()
(v).patch()
(vi).post()
(vii).put()
Above all methods are shortcuts of calling the $http service.

AngularJS Http Method
In above example it EXECUTE the $http service with an object as an argument. And object is specifying the HTTP method , URL and sucess and failure operation details.

Properties
The response we get from server is an object with these below properties:
(1).config:- the object used to generate the request.
(2).data:- it could be a string, or an object, carrying the response from the server.
(3).headers:- a function to use to get header information.
(4).status:- a number defining the HTTP status.
(5).statusText:- a string defining the HTTP status.
Below example will helps you get response with above properties.



AngularJS Http Properties
To handle this errors we will add one more functions to the .then method


AngularJS Http Then



Discussion

No Comment Found