Passing Data To $http.get Request In AngularJS

For More Videos Visit Our YouTube Channel




Here we consider how to pass data to $http.get request. We know how to pass data in POST method in AngularJS.

Passing Data To $http.get Request In AngularJS, How To Pass Data To $http.get Request In AngularJS, $http.get Request Input Parameter, $http.get Request In AngularJS, AngularJS $http.get Request Input Parameter, Pass Data To $http.get Request In AngularJS

But lets consider how does it work when $http.get is used. HTTP GET request can't contain data to be posted to the server. But we can add a query string to the request. angular.http provides an option for this purpose. It is params for passing data in $http.get request.

Passing Data To $http.get Request In AngularJS, How To Pass Data To $http.get Request In AngularJS, $http.get Request Input Parameter, $http.get Request In AngularJS, AngularJS $http.get Request Input Parameter, Pass Data To $http.get Request In AngularJS

In another way we can use params in $http.get as follows.

Passing Data To $http.get Request In AngularJS




Lets start with one example here. First of all, on the Web.Config, include the following section inside System.Web.

Passing Data To $http.get Request In AngularJS

I have created one Web Service named "DataService.asmx". Inside this service, there is a method named GetData. This method have one input parameter named abcd of string data type. We must include [System.Web.Script.Services.ScriptService] on our Service.
The output of this method is serialized as shown below.

Passing Data To $http.get Request In AngularJS

The following given is the Script Side code. Here we have used $Http.get.

The result will be available on the $Http.get then section. Inside $Http.get then, we are binding this result to Scope Object names.

Passing Data To $http.get Request In AngularJS

On the HTML part, we shows the Scope Object value on View as follows.

Passing Data To $http.get Request In AngularJS

When we run the Application, we can get the result as follows.

Passing Data To $http.get Request In AngularJS, How To Pass Data To $http.get Request In AngularJS, $http.get Request Input Parameter, $http.get Request In AngularJS, AngularJS $http.get Request Input Parameter, Pass Data To $http.get Request In AngularJS

By this way we can Pass Data To $http.get Request In AngularJS.