Home
Tutorials
Microsoft Technologies Tutorials
Java Programming Tutorials
Web Designing Tutorials
Script Programming Tutorials
Database Programming Tutorials
Mobile Technologies Tutorials
Other Programming Tutorials
Examples
Articles
Tools
News
AngularJS Http Post Method Example
Keywords : Angularjs http post data example, Angularjs http post service example, Angularjs http post method with parameters example, Angularjs post form data using http post method example
Example
<!DOCTYPE html> <html> <head> <title> AngularJs $http.post() Service Method Example </title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <script type="text/javascript"> var app = angular.module('postserviceApp', []); app.controller('postserviceCtrl', function ($scope, $http) { $scope.name = null; $scope.age = null; $scope.adress = null; $scope.lblMsg = null; $scope.postdata = function (name, age, adress) { var data = { name: name, age: age, adress: adress }; //Call the services $http.post('/api/users/post', JSON.stringify(data)).then(function (response) { if (response.data) $scope.msg = "Post Data Submitted Successfully!"; }, function (response) { $scope.msg = "Service not Exists"; $scope.statusval = response.status; $scope.statustext = response.statusText; $scope.headers = response.headers(); }); }; }); </script> </head> <body> <h2>AngularJS Http Post Method Example</h2> <div ng-app="postserviceApp" ng-controller="postserviceCtrl"> <div> Name : <input ng-model="name" /><br/><br/> Age : <input ng-model="age" /><br/><br/> Adress : <input ng-model="adress" /><br/><br/> <input type="button" value="Send" ng-click="postdata(name, age, adress)" /> <br/><br/> </div> <p>Output Message : {{msg}}</p> <p>StatusCode: {{statusval}}</p> <p>Status: {{statustext}}</p> <p>Response Headers: {{headers}}</p> </div> </body> </html>
Click Here to See Result
Result
Previous
Next