AngularJS Check value in ng-repeat array object

Viewed 26

I will check date with due date in data. If any due date <= date exists it is display true in html, If any due date <= date don't exists it is display false in html (show only 1 value). My data and my javascipt:

$scope.data = {
  project: [
    {
      id: 1,
      dueDate: '2021-10-30 00:00:00.000000',
    },
    {
      id: 2,
      dueDate: '2021-10-10 00:00:00.000000',
    },
    {
      id: 3,
      dueDate: '2021-10-20 00:00:00.000000',
    },
    {
      id: 4,
      dueDate: '2021-10-5 00:00:00.000000',
    },
    {
      id: 5,
      dueDate: '2021-10-2 00:00:00.000000',
    },
  ]
};

// Format date
$scope.date = new Date().setHours(0, 0, 0, 0);
$scope.convertToDate = function(stringDate) {
  var dateOut = new Date(stringDate);
  return dateOut;
};
// Format Due Date
$scope.getDueDate = function(dateTime) {
  return new Date(dateTime).setHours(0, 0, 0, 0);
};

My html:

<div ng-repeat="prj in data.project">
    <div ng-if="date <= getDueDate(prj.dueDate)">
        true
    </div>
    <div ng-if="date > getDueDate(prj.dueDate)">
         false
    </div>
</div>

I want to display with the above data is one value true

0 Answers
Related