0 votes
in Angular by
How to make HTTP Get and Post Calls in Angular?

1 Answer

0 votes
by

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:

JavaScript
function CustomerController($scope,$http)
{
	$scope.Add = function()
	{
            $http({ method: "GET", url: "http://localhost:8438/SomeMethod"     }).success
                  (function (data, status, headers, config)
		{
                   // Here goes code after success
		}
	}
}

$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.
JavaScript
$http({ method: "GET", url: "http://localhost:8438/SomeMethod"    }).success
      (function (data, status, headers, config)
{
// Here goes code after success
}

Related questions

0 votes
asked Dec 31, 2023 in Angular by DavidAnderson
0 votes
asked Dec 31, 2023 in Angular by DavidAnderson
...