I did some tests and calculated how many times the function is called in different circumstances. This happens, the function is called the number of times it has a binding , sometimes twice as many, and it seems that after each external activity , for example, reloading a page or pressing a button or AJAX.
In simple words, if you have <button ng-disabled="noDataFoo()"> and then {{noDataFoo()}} in HTML, the function will be called 4 times when the page loads, then another 2 or 4 times, if any Either the $http service brings data, and the other 2 or 4 times if another button is pressed. From experiments, the number is 2 if noDataFoo does not change and 4 if it changes. By the way, the same applies to clicks on another controller.
My conclusion : it is normal to get attached to fast functions. For longer ones, it is better to keep the number of bindings small. And even for longer ones, it is more reasonable to cache the result and process the cache updates manually.
source share