0

This is my array where I store my pushed data, now I want to send this data to server using http post method.

 $scope.workingSchedules = [{   
     workingDay: 'MONDAY',
     workingHours: [{ 
         fromTime: '1222' ,
         toTime: '1400'
     }]
 }];

This is my code to push data into array.

$scope.addRow = function(){
    $scope.workingSchedules.push({
         'workingDay':'MONDAY',
         'workingHours':[{
             'fromTime':$scope.fromTime,
             'toTime':$scope.toTime
         }]
    });
    $scope.fromTime='';
    $scope.toTime='';
    $scope.workingDay='';
};

How am I suppose to send this array using normal

 $http.post($scope.API_url,
    workingSchedules, config)
    .success(function(workingSchedules, status) {
Andrei Herford
  • 17,570
  • 19
  • 91
  • 225
Helping hand
  • 2,800
  • 2
  • 19
  • 31

1 Answers1

0

You are missing some parts. Content-Type, should be matched to your data.

$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';

Or if you don't want to use $httpProvider :

$http.post($scope.API_url,workingSchedules, config, headers:{'Content-Type':"text/html"})

Look at How to send post request, for the right format of the request.

Community
  • 1
  • 1
Itsik Mauyhas
  • 3,824
  • 14
  • 69
  • 114
  • Hey, thanks for answering!! I have applied conf properly & my post, get ,put works properly. I am having problem in sending the data i pushed into an array in UI and then sending that data back to server. Thanks – Helping hand Jun 22 '16 at 13:00