Hi please see my plunkr below
https://plnkr.co/edit/8cJZsb?p=preview
I have $scope.data which looks like this
$scope.data = [
{
"projectedStart":"2017-01-20T00:00:00"
},
{
"projectedStart":"2017-02-09T00:00:00"
}
];
and $scope.possibleDates that look like this
$scope.possibleDates = [{
"projectedStartDate":"2017-01-25T00:00:00",
"dateName":"January - Week 4 (20/10)"
},
{
"projectedStartDate":"2017-02-01T00:00:00",
"dateName":"February (6/10)"
},
{
"projectedStartDate":"2017-03-01T00:00:00",
"dateName":"March (0/2)"
},
{
"projectedStartDate":"2017-04-05T00:00:00",
"dateName":"April (2/5)"
}]
On the front end dropdown list, I want to be able to display the possibleDates that match closest to the 'projectedStart' date in $scope.data.
I am thinking of doing an angular foreach and looping through each projectedStart date in $scope.data and somehow compare it with each of the dates in $scope.possibleDates and updating $scope.Data's projectedStart with the closest match? Failing miserably so far.
Would greatly appreciate it if someone could point me in the right direction