I have next code (events is array):
<tr ng-repeat="event in events">
<td>
<span time-ago="{{event.TimestampSec}}"></span>
</td>
<td>
{{prepareAlertValue(event.AlertValue)}}
</td>
</tr>
time-ago - my custom directive. It is executed events.length times.
My controller:
...
window.callPrepareAlertValueCount = 0
$scope.prepareAlertValue = function(value) {
window.callPrepareAlertValueCount++;
if(safemineHelper.isFloat(value)) {
value = (~~(value * 100)) / 100;
}
return value;
}
...
After list is shown - I see that callPrepareAlertValueCount grows. Console log:
> callPrepareAlertValueCount
< 41890
> callPrepareAlertValueCount
< 46150
> callPrepareAlertValueCount
< 480315
Please, can someone explain why is prepareAlertValue executed all time. Do I need to write directives for each formatter function?