On this page
Improve this Doc View Source $interval
- service in module ngMock
 
Overview
Mock implementation of the $interval service.
Use $interval.flush(millis) to move forward by millis milliseconds and trigger any functions scheduled to run in that time.
Usage
$interval(fn, delay, [count], [invokeApply], [Pass]);
Arguments
| Param | Type | Details | 
|---|---|---|
| fn | function() | 
        A function that should be called repeatedly.  | 
       
| delay | number | 
        Number of milliseconds between each function call.  | 
       
| count 
          (optional)
           | 
        number | 
        Number of times to repeat. If not set, or 0, will repeat indefinitely. (default: 0)  | 
       
| invokeApply 
          (optional)
           | 
        boolean | 
        If set to  (default: true)  | 
       
| Pass 
          (optional)
           | 
        * | 
        additional parameters to the executed function.  | 
       
Returns
promise | 
       A promise which will be notified on each iteration.  | 
      
Methods
cancel(promise);
Cancels a task associated with the
promise.Parameters
Param Type Details promise promiseA promise from calling the
$intervalfunction.Returns
booleanReturns
trueif the task was successfully cancelled.flush([millis]);
Runs interval tasks scheduled to be run in the next
millismilliseconds.Parameters
Param Type Details millis (optional)numbermaximum timeout amount to flush up until.
Returns
numberThe amount of time moved forward.
© 2010–2018 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
 https://code.angularjs.org/1.6.9/docs/api/ngMock/service/$interval