To make HTTP calls, we need to use the $http
service of Angular. In order to use the http services, you need to provide the $http
as a input in your function parameters as shown in the below code:
function CustomerController($scope,$http)
{
$scope.Add = function()
{
$http({ method: "GET", url: "http://localhost:8438/SomeMethod" }).success
(function (data, status, headers, config)
{
}
}
}
$http
service API needs at least three things:
- First, what is the kind of call
POST
or GET
. - Second, the resource URL on which the action should happen.
- Third, we need to define the
success
function which will be executed once we get the response from the server.
$http({ method: "GET", url: "http://localhost:8438/SomeMethod" }).success
(function (data, status, headers, config)
{
}