2016-09-06 67 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