Skip to content

Instantly share code, notes, and snippets.

/gist:4b6ba8ed5faa1a160f7b Secret
Created Dec 21, 2014

Embed
What would you like to do?
LoansFactory.getLoans().then(function success(response){
var allLoans = response.data.data;
$q.all(
_.map(allLoans, function(obj){
//true if
return LoansFactory.getPendingVotes(obj.id)
.then(function(pvs){
if(pvs.data.data.length == 0){
obj.need_vote = false;
} else {
obj.need_vote = true;
} // end if
return obj;
}),
return LoansFactory.getPendingComments(obj.id)
.then(function(pcs){
if(pcs.data.data.length == 0){
obj.has_comment = false;
} else {
obj.has_comment = true;
} // end if
return obj;
})
})
).then(function(loans){
$scope.loans = loans;
$scope.loanList = _.filter(_.filter(loans,
function(i) { return i.status_id == '1'; }
), function(i){ return i.crop_year == $scope.globals.crop_year});
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.