Here is an example of some HTML code:
<tr ng-repeat="x in y">
<td>
<div ng-attr-id="{{getId()}}"></div>
</td>
<td>
<div ng-attr-id="{{getId()}}"></div>
</td>
<td>
<div ng-attr-id="{{getId()}}"></div>
</td>
</tr>
The goal is to assign a unique id to each <td>
element, starting from 1 and then incrementing by one for each subsequent <td>
element.
To achieve this, a function is created in the controller:
$scope.getId = function () {
counter++;
return counter;
}
However, when implementing this function, the following error occurs:
10 $digest() iterations reached. Aborting!