0

i tried that given the two fields values sends the angular model and then stored in
database through the web API

$scope.Add = function () {
  var EmpModel =
  {
    emp_name: emp_name,
    emp_sallery: emp_sallery,
    emp_designation: emp_designation
  }
  $scope.EmpModel = EmpModel

  $http({
    method: 'Post',
    url: 'Test/EmployeeDataService/EmployeeInformation',
    data: JSON.stringify(EmpModel)
  })
    .then(function (response) {
      $scope.data = response.data;
    },
      function (error) {
        alert(error)
        $scope.DisplayAlert = function (error) {
          alert(error);
        }
      });
}
georgeawg
  • 48,608
  • 13
  • 72
  • 95
  • You need to explain your problem in more detail so other people can help you. Is hard to understand the issue. – f-CJ Aug 25 '18 at 13:30
  • i want to stored the form values in db with angular SPA – SUFIYAN shaikh Aug 25 '18 at 14:06
  • As you're using `asp.net`, its possible that this answer help you: https://stackoverflow.com/a/20276775/9925652 Good luck! – Luiz Carlos Aug 25 '18 at 14:48
  • Please share API Controller code. – dj079 Aug 26 '18 at 10:00
  • There is no need to stringify a JavaScript object as the $http.post method does it automatically. This code sends a JSON string to the server. The problem lies on the server side. We need to see the server side code to help. [From review](https://stackoverflow.com/review/close/20684027). – georgeawg Aug 26 '18 at 10:55

0 Answers0