As you are updating a scope variable polygonDotsCount on click of google map event, the code will run but the changed scope variable never get updated on html. because digest cycle doesn't get run. In order update all binding digest cycle must have have. If you are doing any operation inside the angular context will apply digest cycle properly & will update the binding on html. But when you run any event like onclick or external events like you were using google map event that will never run the digest cycle. You need to run it manually in this case.
When to run $apply
For running digest cycle manually you need to call $apply() method of scope that will run $digest() method and update all the bindings. but directly calling $apply() to run digest cycle would cause an issue, because you sometime it happens while you run digest cycle & if there is already digest cycle running currently then it will throw an error that $digest is already in progress
So better you should use $timeout,
What $timeout does?
It actually run a digest cycle, but it has one advantage. While you wrote a code in $timeout function it will get executed & will run digest cycle. But while running that digest cycle the previous running digest is in progress then it wait till that digest cycle over & then execute after completion of that digest it will run its own digest cycle.
Code
$scope.polygonDotsCount = 0;
$scope.polygonClick = function() {
$timeout(function(){ //<-- inject $timeout on controller before using it.
$scope.polygonDotsCount = $scope.polygonDotsCount + 1;
console.log($scope.polygonDotsCount);
});
};
Using $timeout will ensure that it will never conflict with other
running digest cycle
{{polygonDotsCount}}inside the same controller as the function where you increment it? Provide a jsfiddle.