MCPcopy Index your code
hub / github.com/angular-ui/ui-router / $IntervalProvider

Function $IntervalProvider

test/angular/1.6/angular.js:13461–13661  ·  view source on GitHub ↗

@this

()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

markQExceptionHandledFunction · 0.70

Tested by

no test coverage detected