I attached a function to the scope, and i wanted to run it in a binding, like this:
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
var count = 0;
$scope.f = function () {
count++;
return count;
}
}
html...
<div ng-controller="MyCtrl">
{{f()}}
</div>
but when i run it, the function returns 11, as you can check on this fiddle: http://jsfiddle.net/h4w4yc6L/
it seems like the function is running several times, even though i only call it once on the html, because my console complains about
angular.js:13920
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
please do be aware that i am really newbie on angular! i don't know why this is happening, so I will be really glad if you provide me with information about why this happens, how to avoid this, and what is the right way to achieve this...
thanks in advance :)