1
你能幫我解決這個問題嗎?如何遍歷結果的元素? angular.forEach(results.first,函數(值,鍵){//什麼}不太多的承諾工作。
var AppControllers = angular.module('AppControllers', ['AppConfig']);
AppControllers.controller('WorkItemController', ['$scope', '$q', 'IStatus', 'SRStatus',
function($scope, $q, IStatus, SRStatus) {
$q.all({
first: IStatus.get(),
second: SRStatus.get()
}).then(function(results) {
console.log(results);
//return Object { first=[0], second=[0]}
console.log(results.first);
//return
//[]
//0 Resource { Displayable=true, Changeable=true, Open=true, mais...}
//1 Resource { Displayable=true, Changeable=true, Open=true, mais...}
//2 Resource { Displayable=false, Changeable=false, Open=false, mais...}
//3 Resource { Displayable=true, Changeable=false, Open=true, mais...}
//$promise Object { $$state={...}, then=function(), catch=function(), mais...}
//$resolved true
console.log(results.first.length);
//return 0
console.log(results.first[1]);
//return undefined
});
}]);
非常感謝你 – 2014-11-21 18:23:05