Today I had to fix a performance issue caused by this code: Pay attention to updateStats called inside the template
<script type="text/ng-template" id="entityGrouper">
<section>
<div>
<ul ng-click="hideEntityBox = !hideEntityBox">
<li>
{{ entityNode.name }}
</li>
<li ng-repeat="breadcrumbItem in entityNode.breadcrumb">
{{ breadcrumbItem }}
</li>
</ul>
{{ updateStats(entityNode) }}
<span ng-include="'/mypath/views/resume.html'"></span>
</div>
<div>
<div ng-repeat="entityNode in entityNode.group" ng-include="'entityGrouper'"></div>
<div ng-repeat="entity in entityNode.group" ng-include="'entityBox'"></div>
</section>
</script>
Template use:
<div ng-repeat="entityNode in entityNode.group" ng-include="'entityGrouper'"></div>
After debugging this code I discovered that this function was called many more time than the array size (my array has 4 objects and the function was called more than 100 times), even mouse hover called this function. I fixed that by just putting a ng-init inside the template and now it's working properly, but I didn't figure out why this function has been called so many times. Is there something about two way data binding?