I'm making a task management widget that displays tasks based on if they are in the current day, week or month. I'd like to push dates into weeklyTaskArray, dailyTaskArray, monthlyTaskArray and render them using .length.
What I have tried:
$http({
method: 'GET',
url: 'http://localhost:3000/api/tasks.json',
}).then(function(response) {
let tasks = response.data;
angular.copy(tasks, taskArray)
tasks.filter(function(element) {
if (`${element.due_date} === "5/17/16" && ${element.due_date} === "5/19/16"`) {
console.log("in the function",element.due_date);
angular.copy(element, weeklyTaskArray);
console.log("this is the task array", weeklyTaskArray.length);
} else if (element.due_date === "5/20/17") {
angular.copy(element, monthlyTaskArray);
} else if (element.due_date === "5/15/17") {
angular.copy(element, dailyTaskArray);
}
})
});
The function above pushes the entire data set into the weeklyTaskArray. Here is the data set:
[
{
"id": 1,
"name": "Test Task",
"due_date": "5/17/2016"
},
{
"id": 2,
"name": "Atlatl Task",
"due_date": "5/19/2016"
},
{
"id": 3,
"name": "PriceBooks Task",
"due_date": "5/20/2016"
}
]