0
的 “类型” 工作的每个循环是在格式["hourAverage","hourMedian","dayAverage","dayMedian","weekAverage","weekMedian","monthAverage","monthMedian"]
对于承诺不处于被传递参数angularjs
来源:
$scope.buildCharts = function(types){
var deferred = $q.defer();
var promises = [];
types.forEach(function(type){
$scope.prepareData(type);
deferred.resolve([
{
title: type,
curveType: 'function',
legend: { position: 'bottom' }
},type]);
promises.push(deferred.promise);
});
return $q.all(promises);
};
输出:
[
[
{
"title": "hourAverage",
"curveType": "function",
"legend": {
"position": "bottom"
}
},
"hourAverage"
],
[
{
"title": "hourAverage",
"curveType": "function",
"legend": {
"position": "bottom"
}
},
"hourAverage"
],
[
{
"title": "hourAverage",
"curveType": "function",
"legend": {
"position": "bottom"
}
},
"hourAverage"
],
[
{
"title": "hourAverage",
"curveType": "function",
"legend": {
"position": "bottom"
}
},
"hourAverage"
],
[
{
"title": "hourAverage",
"curveType": "function",
"legend": {
"position": "bottom"
}
},
"hourAverage"
],
[
{
"title": "hourAverage",
"curveType": "function",
"legend": {
"position": "bottom"
}
},
"hourAverage"
],
[
{
"title": "hourAverage",
"curveType": "function",
"legend": {
"position": "bottom"
}
},
"hourAverage"
],
[
{
"title": "hourAverage",
"curveType": "function",
"legend": {
"position": "bottom"
}
},
"hourAverage"
]
]