$http can be used to get data on a Web service, or to pass a JSON server over a POST request
The main use of the $http.get () and post () two methods.
$http. Get () Gets the data to the server through a GET method. Main methods of Use:
1. The first form of notation
$http. Get (URL)
. seccess (function (response)
{
Todo
})
. Error (function (Exception)
{
Todo
});
2. The second type of notation
$http (
{
Method: ' GET ',
URL: '/api/users.json ',
params:{
' username ': ' Tan '
});
$http Post method is possible to transfer data to the server, if you do not set the upload format, the default is the use of JSON, the main way to use:
$http (
{
URL: ' Http://localhost:8080/user/register ',
Method: ' POST ',
Data: ' {' name ': ' Jimmy ', ' Age ': 12} '
})
. Success (function (data)
{
alert (data);
});
Data can be a string or an object
Angular JS $http service use