I have this code:
$scope.showReport = function(datas){
data.post('dailyReservationReport',{date:$scope.date}).then(function (response){
$scope.reports = response.data;
console.log($scope.reports);
var sum =0;
for(var index in $scope.reports){
if($scope.reports[index].departuredate == "2015-03-11"){
sum += $scope.reports[index].departuredate;
}
}
console.log(sum);
})
};
The problem I was have is I want to get the sum of data with departure date which is equal to 2015-03-11. I have 2 data so the sum should output 2.
But this is the results in my console.log:
02015-03-112015-03-11
What I did wrong? Please help
sum += $scope.reports[index].dataor whatever key it has instead ofdata