I am trying to use $timeout (or $interval) and from the docs and numerous examples on the web counting in 1 second increments is easy:
var counter = 0;
$timeout(timer(), 1000);
var timer = function() {
counter++;
$timeout(timer(), 1000);
};
When calling $timeout with 1 millisecond increments, however, the time is not accurate. Here is an example: http://jsfiddle.net/eh8o9s28/
If you run the timer in the example it looks OK, but compare to a stopwatch and after about 20 seconds the Angular time is about 2 seconds wrong, and it continues to diverge from there. (Note that if you change the increment to 1000, the time is perfectly accurate.)
Any ideas? I am wondering whether millisecond increments is too fast for the $digest
cycle to keep up with?