【发布时间】:2016-10-24 07:34:26
【问题描述】:
这是我存储推送数据的数组, 现在我想使用 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) {
【问题讨论】:
-
你的数据应该是一个对象,所以让它变成这样 $http.post($scope.API_url, {data: workingSchedules}, config),发帖前请检查问题是否已经存在,请参阅下面的评论。
标签: javascript html arrays angularjs