【发布时间】:2016-09-06 09:22:31
【问题描述】:
如何在 AngularJS 中发送这些数据。 (这是一个多重数组中的多重数组,需要在一个对象上发送)
[{
"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;
}
}); */
};
现在我只需要用angular js发送这个数据格式,请建议
这就是我通过“硬代码”在 Angular 中所做的事情,我需要在 Angular js 中发送这些数据,我该怎么做?
现在请帮助我使用 Angular 的 html 代码将硬编码值发送到用户的运行时值
【问题讨论】:
-
你想从 angularjs 发送数据还是想用 angularjs 显示这些数据?
-
相应地发送和获取
-
你想在 HTML 中也显示这些数据吗?
-
是的......我也想获取并显示它的html
-
你应该使用
$http服务DOC
标签: angularjs arrays json angularjs-scope