AngularJs Pass Data to $http.get request


AngularJs Pass Data to $http.get request Method – Data in $http.get request method are passed in params which are posted to server. Here in this tutorial we are going to explain how you can post parameters using the $http.get request method to the server. We are going to explain this with syntax and example.


AngularJs Pass Data to $http.get request / Pass parameters

Here is syntax and example for passing the parameters to the $http.get request method –

Syntax

AngularJs Pass Data to $http.get request Method Syntax:

$http.get(url, {
    params: { param1: value1, param2:value2, param3:value3...... }
});

Where url is the path to perform get request on server. param1, param2 ..and value1, value2.. are parameter and values that you want to post using the $http.get method in angularjs.

Example

AngularJs Pass Data to $http.get request Method Example:

$http.get("www.yourdomain.com/getData.php", {
    params: { id: '100', name:'john', email:'john@yopmail.com' }
});

In the above example we have passed the id, name and email along with its values using $http.get request method. Thus you can post any data using the $http.get method.


Advertisements

Add Comment

📖 Read More