2016-09-06 66 views
-1

如何在AngularJS中发送这些数据。 (这是在多阵列的多阵列,需要发送一个对象)在Angular js中发送多个数组的多个数组

[{ 
"working_day":"sunday", 
"from_time":{"hour":"9","min":"30"}, 
"to_time":{"hour":"6","min":"30"} 
},{ 
"working_day":"monday", 
"from_time":{"hour":"9","min":"30"}, 
"to_time":{"hour":"6","min":"30"}... and so on for other week days 
}] 

我试图在API中发送数据,这样,我是新来AngularJs,所以请告诉我,我该怎么做这些数据在运行时通过HTML?

  $scope.schedule = []; // Hard coded value 
      $scope.week = {}; 
      $scope.week.working_day = "Sunday"; 
      $scope.week.from_time = {}; 
      $scope.week.from_time.min = "10:00"; 
      $scope.week.from_time.max = "5:00"; 
      $scope.week.to_time = {}; 
      $scope.week.to_time.min = "2:10"; 
      $scope.week.to_time.max = "8:00"; 

    var dataParam = { 
         "prefix":$scope.data1.prefix, 
         "first_name":$scope.data1.first_name, 
         "password":$scope.data1.password, 
         "last_name":$scope.data1.last_name, 
         "email_id":$scope.data1.email_id, 
         "mobile_number":$scope.data1.mobile_number, 
         "roleCode":[$scope.data1.roleCode], 
         "role":[$scope.data1.role], 
         "Schedule":angular.toJson($scope.schedule.push($scope.week)) 

         } 
console.log(angular.toJson(dataParam)); 
      /* $http({ 
      url: "/here", 
      method: "POST", 
      headers :{'Content-Type': 'application/json','Accept': 'application/json' }, 
      data: dataParam 
      }) .success(function(response) { 
       if(response.status_code=="success") 
       { 
        $scope.successmsg = response.status_message; 

      console.log(angular.toJson(response)); 
      $state.go('dashboard.setting.user', {'user': $scope.viewUser}); 
       } 
       else { 

       $scope.successmsg = response.status_code; 
       } 

      }); */ 

};

现在我只需要具有角JS发送这个数据格式,请建议

这是我在角由“硬编码”做我需要发送的角度JS这个数据,我怎么能去做?

现在,请帮助我的角度HTML代码的用户到该硬编码值发送到运行值

+0

你想从angularjs发送数据或想要使用angularjs显示这些数据? –

+0

发送并取回相应的 – adasdasd

+0

是否要在HTML中显示此数据? –

回答

0

有一个数组

$scope.schedule = []; 

与您的JSON键创建一个对象

$scope.week = {}; 
$scope.week.working_day = ""; 
$scope.week.from_time = {}; 
$scope.week.from_time.min = ""; 
$scope.week.from_time.max = ""; 
$scope.week.to_time = {}; 
$scope.week.to_time.min = ""; 
$scope.week.to_time.max = ""; 

将其推入阵列

$scope.schedule.push($scope.week); 
+0

谢谢但时间数组呢? – adasdasd

+0

它只返回1 – adasdasd

+0

再返回1 – adasdasd