这是我存储推送数据的数组, 现在我想使用http post方法将此数据发送到服务器。
$scope.workingSchedules = [{
workingDay: 'MONDAY',
workingHours: [{
fromTime: '1222' ,
toTime: '1400'
}]
}];
这是我将数据推送到数组的代码。
$scope.addRow = function(){
$scope.workingSchedules.push({
'workingDay':'MONDAY',
'workingHours':[{
'fromTime':$scope.fromTime,
'toTime':$scope.toTime
}]
});
$scope.fromTime='';
$scope.toTime='';
$scope.workingDay='';
};
我怎么想用普通的
发送这个数组 $http.post($scope.API_url,
workingSchedules, config)
.success(function(workingSchedules, status) {
答案 0 :(得分:0)
你缺少一些零件。
Content-Type
应与您的数据匹配。
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
或者,如果您不想使用$httpProvider
:
$http.post($scope.API_url,workingSchedules, config, headers:{'Content-Type':"text/html"})
查看How to send post request,format
的{{1}}。