// Here goes the JavaScript code
var app = angular.module('myApp', []);
app.controller('MainCtrl', function($scope) {
$scope.number = 31;
$scope.getNumber = function (num) {
return new Array(num);
};
$scope.emprecords = [
{
"id": "1",
"name": "Franz Ebert",
"address": "804 Parker Meadows Suite 326\nBryanafurt, VA 07882",
"phone": "(495) 696-7004 x4828",
"mobile": "574-670-6661 x966",
"place": "Lake Nickolas",
"basic": "5098.00",
"ta": "846.00",
"da": "833.00",
"hra": "743.00",
"medical": "583.00",
"total": "918.00",
"joinDate": "1976-09-28",
"releavingDate": "1979-03-30",
"employeeType": "Non Office Staff",
"photo": "profile.jpg",
"active": "1",
"created_at": "2016-10-06 03:53:18",
"updated_at": "2016-10-06 03:53:18",
"attendance": [
{
"id": "1",
"employees_id": "1",
"date": "2015-03-04",
"present": "1",
"note": "parayathea poyi",
"remark": "edited",
"created_at": "2016-10-06 03:53:42",
"updated_at": "2016-10-06 06:35:55",
"day": 4
},
{
"id": "2",
"employees_id": "1",
"date": "2015-03-05",
"present": "0",
"note": "",
"remark": "Sequi ut quam recusandae sed delectus harum.",
"created_at": "2016-10-06 03:53:42",
"updated_at": "2016-10-06 03:53:42",
"day": 5
},
{
"id": "3",
"employees_id": "1",
"date": "2015-03-03",
"present": "1",
"note": "",
"remark": "Est nihil omnis consectetur ut vel eligendi accusantium voluptas.",
"created_at": "2016-10-06 03:53:42",
"updated_at": "2016-10-06 03:53:42",
"day": 6
},
{
"id": "4",
"employees_id": "1",
"date": "2015-03-04",
"present": "0",
"note": "",
"remark": "A at totam autem cumque.",
"created_at": "2016-10-06 03:53:42",
"updated_at": "2016-10-06 03:53:42",
"day": 7
}
]
}];
$scope.wasPresent = function (emp, day) {
for (var i=0, iLen=$scope.emprecords[emp].attendance.length; i<iLen; i++) {
if ($scope.emprecords[emp].attendance[i].day == day) return true;
}
return false;
};
});
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta charset="utf-8" />
<title>AngularJS Application</title>
<link data-require="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3e5c51514a4d4a4c5f4e135d4d4d7e0d100d1008">[email protected]</a>" data-semver="3.3.6" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css" />
<link data-require="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="77151818030403051607374459445941">[email protected]</a>" data-semver="3.3.6" rel="stylesheet" href="bootstrap" />
<script>
document.write('<base href="' + document.location + '" />');
</script>
<link rel="stylesheet" href="style.css" />
<script data-require="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bbdad5dcced7dac995d1c8fb8a958e95c3">[email protected]</a>" src="https://code.angularjs.org/1.5.8/angular.js" data-semver="1.5.8"></script>
<script src="script.js"></script>
</head>
<body ng-controller="MainCtrl">
<p>Hello {{name}}!</p>
<table class="table table-bordered">
<thead>
<th>Name</th>
<th ng-repeat="(key, i) in getNumber(number) track by $index" ng-data="{{key}}">{{$index+1}}</th>
</thead>
<tbody>
<tr ng-repeat="(key,employee) in emprecords">
<td>{{employee.name}}</td>
<td ng-repeat="(key2, i2) in getNumber(number) track by $index" ng-data="{{key2}}">{{ wasPresent(key, ($index + 1)) ? 'p' : 'a'}} </td>
</tr>
</table>
</body>
</html>