From 35a5ee5c113f4614d9ce69140bc444e832eaab12 Mon Sep 17 00:00:00 2001 From: Josh Kurz Date: Thu, 12 Dec 2013 01:39:40 -0500 Subject: [PATCH] docs(interval.js) alerting the developer Many times $intervals are used inside of directives or controllers. If a directive/controller is destroyed, then the $interval should be destroyed as well. The interval created by this service does not have a way to track an associated $scope. This could cause some issues with developers who assume that the $interval will be cleared for them when the $scope is destroyed. I believe that the library could/should handle this as well, but thats another issue. --- src/ng/interval.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ng/interval.js b/src/ng/interval.js index 2ad3a7f158a0..61f1349fdfa3 100644 --- a/src/ng/interval.js +++ b/src/ng/interval.js @@ -24,6 +24,12 @@ function $IntervalProvider() { * In tests you can use {@link ngMock.$interval#methods_flush `$interval.flush(millis)`} to * move forward by `millis` milliseconds and trigger any functions scheduled to run in that * time. + * + *
+ * **Note**: The interval craeted by this service is not cleared during the $scope.$destroy() event. + * The developer should take this into consideration and make sure to always cancel the interval + * inside a broadcasted 'destroy' event. + *
* * @param {function()} fn A function that should be called repeatedly. * @param {number} delay Number of milliseconds between each function call.