I need help figuring out how to count the number of 'td' elements generated in a loop.
Using $index
isn't working for me because it resets on each row, causing confusion with setting 'i' for each iteration. What is the best and simplest way to ensure that the first column value is 1 and the first column count starts at 0?
This is what my code looks like currently:
<table class="calendar">
<thead>
<tr>
<th>M</th>
<th>T</th>
<th>W</th>
<th>T</th>
<th>F</th>
<th>S</th>
<th>S</th>
</tr>
</thead>
<tbody ng-click="bindCellValue($event)">
<tr ng-repeat="week in (days.length/7 | array)">
<td ng-repeat="day in days.slice(7*$index, 7*$index + 7) track by $index">
{{ day }}
<i class="icon ion-checkmark answer-correct" ng-if="submitted && answers[i].correct"></i>
<i class="icon ion-close answer-wrong" ng-if="submitted && !answers[i].correct"></i>
</td>
</tr>
</tbody>
</table>
In my controller, I have defined the following:
$scope.days = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, null, null, null, null ];