JSFiddle - React, Tailwind, and code Playground
HTML
<html ng-app>
<body ng-controller="TodoCtrl">
<table id="audit-program-table" class="table display nowrap" width="100%">
<thead>
<tr>
<th ng-repeat="month in months" colspan="{{month.totalWeeks}}">{{month.name}}</th>
</tr>
<tr>
<th class="week-number-class" ng-repeat="month in months[0].weeks" >{{$index+1}}</th>
<th class="week-number-class" ng-repeat="month in months[1].weeks" >{{$index+1}}</th>
<th class="week-number-class" ng-repeat="month in months[2].weeks" >{{$index+1}}</th>
<th class="week-number-class" ng-repeat="month in months[3].weeks" >{{$index+1}}</th>
<th class="week-number-class" ng-repeat="month in months[4].weeks" >{{$index+1}}</th>
<th class="week-number-class" ng-repeat="month in months[5].weeks" >{{$index+1}}</th>
<th class="week-number-class" ng-repeat="month in months[6].weeks" >{{$index+1}}</th>
<th class="week-number-class" ng-repeat="month in months[7].weeks" >{{$index+1}}</th>
<th class="week-number-class" ng-repeat="month in months[8].weeks" >{{$index+1}}</th>
<th class="week-number-class" ng-repeat="month in months[9].weeks" >{{$index+1}}</th>
<th class="week-number-class" ng-repeat="month in months[10].weeks" >{{$index+1}}</th>
<th class="week-number-class" ng-repeat="month in months[11].weeks" >{{$index+1}}</th>
<th class="week-number-class" ng-repeat="month in months[12].weeks" >{{$index+1}}</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</body>
</html>
CSS
.week-number-class {
padding: 0!important;
margin: 0!important;
max-width: 3px;
}
table, table th {
border: 1px solid grey;
}
JavaScript
function TodoCtrl($scope) {
$scope.filter = {
"year": ''+new Date().getFullYear()
};
$scope.months = [
{"name": "Jan","number": 1, "totalWeeks": null, "weeks": null},
{"name": "Feb","number": 2, "totalWeeks": null, "weeks": null},
{"name": "Mar","number": 3, "totalWeeks": null, "weeks": null},
{"name": "Apr","number": 4, "totalWeeks": null, "weeks": null},
{"name": "May","number": 5, "totalWeeks": null, "weeks": null},
{"name": "Jun","number": 6, "totalWeeks": null, "weeks": null},
{"name": "Jul","number": 7, "totalWeeks": null, "weeks": null},
{"name": "Aug","number": 8, "totalWeeks": null, "weeks": null},
{"name": "Sep","number": 9, "totalWeeks": null, "weeks": null},
{"name": "Oct","number": 10, "totalWeeks": null, "weeks": null},
{"name": "Nov","number": 11, "totalWeeks": null, "weeks": null},
{"name": "Dec","number": 12, "totalWeeks": null, "weeks": null}
];
$scope.auditProgramList = [];
$scope.getTotalWeekOfAMonth = function(year, month) {
var firstOfMonth = new Date(year, month - 1, 1);
var day = firstOfMonth.getDay() || 6;
day = day === 1 ? 0 : day;
if (day) { day-- }
var diff = 7 - day;
var lastOfMonth = new Date(year, month, 0);
var lastDate = lastOfMonth.getDate();
if (lastOfMonth.getDay() === 1) {
diff--;
}
var result = Math.ceil((lastDate - diff) / 7);
return result + 1;
}
$scope.createWeeksNumberList = function() {
$scope.months.forEach(function(element) {
var weekTotals = $scope.getTotalWeekOfAMonth($scope.filter.year, element.number);
var obj = [];
for (let week = 1; week <=...