<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>Processing $http.post() response in service</title>
  <script src="https://code.angularjs.org/1.3.0-beta.5/angular.js"></script>
  <script>
    var app = angular.module('myServiceApp', []);

    app.controller('myServiceCtrl', function($scope) {
      $scope.name = null; //default
      $scope.age = null; //default
      $scope.adress = null; //default

      $scope.lblMsg = null; //default

      $scope.postdata = function(name, age, adress) {
        var data = {
          name: name,
          age: age,
          adress: adress
        };
        alert(JSON.stringify(data));
        //Call the services
        $http.post('htpp://localhost:8080/api/users/post', JSON.stringify(data)).then(function(rest, status) {
            if (status) {
              if (rest.data)
                $scope.lblMsg = "post data submit successfully!";
            } else {
              $scope.lblMsg = "faild!";
            }
          });
     };
    
    });
  </script>
</head>

<body ng-app="myServiceApp">
  <div ng-controller="myServiceCtrl">
    <div>
      Name :
      <input ng-model="name" />
      <br> Age :
      <input ng-model="age" />
      <br> Adress :
      <input ng-model="adress" />
      <br>
      <a href="#" ng-click="postdata(name, age, adress)">Send</a>
      <br> Output Message : {{ $scope.lblMsg}}
    </div>
  </div>
</body>

</html>
// Code goes here

/* Styles go here */