@this
()
| 13486 | |
| 13487 | /** @this */ |
| 13488 | function $IntervalProvider() { |
| 13489 | this.$get = ['$rootScope', '$window', '$q', '$$q', '$browser', |
| 13490 | function($rootScope, $window, $q, $$q, $browser) { |
| 13491 | var intervals = {}; |
| 13492 | |
| 13493 | |
| 13494 | /** |
| 13495 | * @ngdoc service |
| 13496 | * @name $interval |
| 13497 | * |
| 13498 | * @description |
| 13499 | * AngularJS's wrapper for `window.setInterval`. The `fn` function is executed every `delay` |
| 13500 | * milliseconds. |
| 13501 | * |
| 13502 | * The return value of registering an interval function is a promise. This promise will be |
| 13503 | * notified upon each tick of the interval, and will be resolved after `count` iterations, or |
| 13504 | * run indefinitely if `count` is not defined. The value of the notification will be the |
| 13505 | * number of iterations that have run. |
| 13506 | * To cancel an interval, call `$interval.cancel(promise)`. |
| 13507 | * |
| 13508 | * In tests you can use {@link ngMock.$interval#flush `$interval.flush(millis)`} to |
| 13509 | * move forward by `millis` milliseconds and trigger any functions scheduled to run in that |
| 13510 | * time. |
| 13511 | * |
| 13512 | * <div class="alert alert-warning"> |
| 13513 | * **Note**: Intervals created by this service must be explicitly destroyed when you are finished |
| 13514 | * with them. In particular they are not automatically destroyed when a controller's scope or a |
| 13515 | * directive's element are destroyed. |
| 13516 | * You should take this into consideration and make sure to always cancel the interval at the |
| 13517 | * appropriate moment. See the example below for more details on how and when to do this. |
| 13518 | * </div> |
| 13519 | * |
| 13520 | * @param {function()} fn A function that should be called repeatedly. If no additional arguments |
| 13521 | * are passed (see below), the function is called with the current iteration count. |
| 13522 | * @param {number} delay Number of milliseconds between each function call. |
| 13523 | * @param {number=} [count=0] Number of times to repeat. If not set, or 0, will repeat |
| 13524 | * indefinitely. |
| 13525 | * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise |
| 13526 | * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block. |
| 13527 | * @param {...*=} Pass additional parameters to the executed function. |
| 13528 | * @returns {promise} A promise which will be notified on each iteration. It will resolve once all iterations of the interval complete. |
| 13529 | * |
| 13530 | * @example |
| 13531 | * <example module="intervalExample" name="interval-service"> |
| 13532 | * <file name="index.html"> |
| 13533 | * <script> |
| 13534 | * angular.module('intervalExample', []) |
| 13535 | * .controller('ExampleController', ['$scope', '$interval', |
| 13536 | * function($scope, $interval) { |
| 13537 | * $scope.format = 'M/d/yy h:mm:ss a'; |
| 13538 | * $scope.blood_1 = 100; |
| 13539 | * $scope.blood_2 = 120; |
| 13540 | * |
| 13541 | * var stop; |
| 13542 | * $scope.fight = function() { |
| 13543 | * // Don't start a new fight if we are already fighting |
| 13544 | * if ( angular.isDefined(stop) ) return; |
| 13545 | * |
nothing calls this directly
no test coverage detected