| 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