Can someone tell me what I'm doing wrong? I have JSON data that I'm converting to an array for an ng-repeat. Before I iterate through the array, I am comparing the event dates to today's date and splicing the ones that have already passed. However, for some reason, the only thing in the splice getting respected is the deleteCount.
angular.forEach($scope.training, function(event, date) {
var d = event.endDate;
var evDate = d.toString();
console.log(evDate);
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
dd='0'+dd;
}
if(mm<10) {
mm='0'+mm;
}
today = mm+'/'+dd+'/'+yyyy;
console.log(today);
var d1 = Date.parse(evDate);
var d2 = Date.parse(today);
console.log(d1+','+d2);
if (d1 <= d2) {
$scope.training.splice(event,1);
} else { return false; }
});
and a sample of the JSON:
{"name": "Name","date": "Jan 18","location": "Houston, TX","endDate": "01/19/2016"}