<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="https://code.angularjs.org/1.4.1/angular.js" data-semver="1.4.1" data-require="angular.js@1.4.1"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body ng-controller="TestController">
<h1>test date: 2015-06-28</h1>
<table>
<tr class="header">
<td>Id</td>
<td>date</td>
<td>is < 14 days</td>
<td>dateExpires</td>
<td>is < 14 days</td>
<td>dateUpdate</td>
<td>is < 14 days</td>
</tr>
<tr ng-repeat="dat in data">
<td>
{{::dat.id}}
</td>
<td>
{{::dat.date}}
</td>
<td>
<div class="inline" ng-show="daysDiff(dat.date) < 14">)YES</div>
</td>
<td>
{{::dat.dateExpires}}
</td>
<td>
<div class="inline" ng-show="daysDiff(dat.dateExpires) < 14">YES</div>
</td>
<td>
{{::dat.dateUpdate}}
</td>
<td>
<div class="inline" ng-show="daysDiff(dat.dateUpdate) < 14">YES</div>
</td>
</tr>
</table>
<script src="script.js"></script>
</body>
</html>
// Code goes here
(function(){
app = angular.module('app',[]);
app.controller('TestController',function($scope){
var data = [];
for (var i = 0; i < 20; i++) {
var obj = {
id: i,
date: "2015-05-" + (i + 7), //date created
dateExpires: "2015-07-" + ((i<3) ? ("0"+(i + 7)) : (i + 7)), //date expires
dateUpdate: "2015-06-" + (i + 7), //date last update
};
data.push(obj);
}
$scope.daysDiff = function (date) {
var dateobj = new Date(date);
var current = new Date("2015-06-28");
var resultDays = Math.floor(Math.abs((current - dateobj) / (86400000))); //1k *60*60*24
return resultDays;
};
$scope.data = data;
});
})();
/* Styles go here */
.inline{
display: inline;
}
table{
}
tr.header{
border: 1px red solid;
}
td{
border: 1px lightgray solid;
}