I am using a function to count the number of clicks on the button as shown below:
$scope.counterFunc = (function(){
var count = 0;
console.log('i will be consoled only once');
return function(){
console.log(count);
return ++count;
}
})();
View:
<button ng-click="counterFunc()">click me</button>
<div>
{{ count value }}
</div>
I am able to console the count value, but how can i display it in the view.
I can use $scope variable to bind count value to view but my concern is that the count should not be altered by any other function outside the counterFunc()
Is there any other way to do this?..