使用Angularjs发布从UI推送的数据数组

时间:2016-06-24 06:48:32

标签: javascript html css angularjs json

我创建了一个数组来通过UI推送数据,我想要的是使用angularjs post发送创建的数组。

这是我的代码: -

$scope.clinicWorkingSchedules = [ 
        {   workingDay: '',
            workingHours: []
        }
      ]

  $scope.sendClinicTiming= function(id,workingDay,fromTime,toTime){

   var data={
          'id':id,
          'clinicWorkingSchedules':clinicWorkingSchedules
         };
   $http.post($scope.API_url,
    data, config)
    .success(function(data, status));


  };

id正常,但无法发送数组。 任何帮助表示赞赏。 感谢

3 个答案:

答案 0 :(得分:0)

window.document

答案 1 :(得分:0)

$scope.clinicWorkingSchedules =  
        {   workingDay: '',
            workingHours: {'fromTime':'', 'toTime':''}
        }


$scope.sendClinicTiming= function(id,workingDay,fromTime,toTime){

$scope.clinicWorkingSchedules.workingDay = workingDay;
$scope.clinicWorkingSchedules.workingHours.fromTime = fromTime;
$scope.clinicWorkingSchedules.workingHours.toTime= toTime;


   var data={
          'id':id,
          'clinicWorkingSchedules':$scope.clinicWorkingSchedules
         };
   $http.post($scope.API_url,
    data, config)
    .success(function(data, status));

  };

答案 2 :(得分:0)

您忘记在数组前添加$scope。其余的代码完全没问题。这是带有更改的代码。

var data={
    'id':id,
    'clinicWorkingSchedules': $scope.clinicWorkingSchedules
};