Angularjs pass parameters to $http post – Data in $http.post request method are passed in params which are posted to server. Here in this tutorial we are going to explain how you can post data(parameters) using the $http.post request method to the server. We are going to explain this with syntax and example.
Angularjs pass parameters to $http post / Post Data
Here is syntax and example for passing the parameters to the $http.post request method –
Syntax
AngularJs Pass Data to $http.post request Method Syntax:
$http.post(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.post method in angularjs.
Example
AngularJs Pass Data to $http.post request Method Example:
$http.post("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.post request method. Thus you can post any data using the $http.post method.