angular-ui/bootstrap — pull request #1423 by joshkurz (2013-12-17 06:21:19+00:00)
Title: fix(carousel): using setInterval to get rid of dangling $timeouts

There are a couple issues with how the carousel currently handles its interval functionality.

1. When Angular runs its digest loop, two $timeouts are set each iteration. These timeouts are not clearing correctly on the browser window. During the digest iterations, currentTimeout is being overwritten multiple times and its relevant timeout promise object is lost in the carousel's controller context. Normally this would not be an issue, but since the timeout sets more timeouts, it is.

2. In #1414 it was stated that the cancel method needed to be called in the $destroy event. This is still true, but does not fix issue 1.

This PR uses setInterval instead of $timeout.

If we switched to using $timeout in the 1.2.x branch, everything would still work the same. The syntax would be a little cleaner and the tests would not have a need for the jasmine.clock object.