-
ng
- function
- angular.UNSAFE_restoreLegacyJqLiteXHTMLReplacement
- angular.bind
- angular.bootstrap
- angular.copy
- angular.element
- angular.equals
- angular.errorHandlingConfig
- angular.extend
- angular.forEach
- angular.fromJson
- angular.identity
- angular.injector
- angular.isArray
- angular.isDate
- angular.isDefined
- angular.isElement
- angular.isFunction
- angular.isNumber
- angular.isObject
- angular.isString
- angular.isUndefined
- angular.merge
- angular.module
- angular.noop
- angular.reloadWithDebugInfo
- angular.toJson
- directive
- a
- form
- input
- input[checkbox]
- input[date]
- input[datetime-local]
- input[email]
- input[month]
- input[number]
- input[radio]
- input[range]
- input[text]
- input[time]
- input[url]
- input[week]
- ngApp
- ngBind
- ngBindHtml
- ngBindTemplate
- ngBlur
- ngChange
- ngChecked
- ngClass
- ngClassEven
- ngClassOdd
- ngClick
- ngCloak
- ngController
- ngCopy
- ngCsp
- ngCut
- ngDblclick
- ngDisabled
- ngFocus
- ngForm
- ngHide
- ngHref
- ngIf
- ngInclude
- ngInit
- ngJq
- ngKeydown
- ngKeypress
- ngKeyup
- ngList
- ngMaxlength
- ngMinlength
- ngModel
- ngModelOptions
- ngMousedown
- ngMouseenter
- ngMouseleave
- ngMousemove
- ngMouseover
- ngMouseup
- ngNonBindable
- ngOn
- ngOpen
- ngOptions
- ngPaste
- ngPattern
- ngPluralize
- ngProp
- ngReadonly
- ngRef
- ngRepeat
- ngRequired
- ngSelected
- ngShow
- ngSrc
- ngSrcset
- ngStyle
- ngSubmit
- ngSwitch
- ngTransclude
- ngValue
- script
- select
- textarea
- object
- angular.version
- type
- $cacheFactory.Cache
- $compile.directive.Attributes
- $rootScope.Scope
- ModelOptions
- angular.Module
- form.FormController
- ngModel.NgModelController
- select.SelectController
- provider
- $anchorScrollProvider
- $animateProvider
- $compileProvider
- $controllerProvider
- $filterProvider
- $httpProvider
- $interpolateProvider
- $locationProvider
- $logProvider
- $parseProvider
- $qProvider
- $rootScopeProvider
- $sceDelegateProvider
- $sceProvider
- $templateRequestProvider
- service
- $anchorScroll
- $animate
- $animateCss
- $cacheFactory
- $compile
- $controller
- $document
- $exceptionHandler
- $filter
- $http
- $httpBackend
- $httpParamSerializer
- $httpParamSerializerJQLike
- $interpolate
- $interval
- $jsonpCallbacks
- $locale
- $location
- $log
- $parse
- $q
- $rootElement
- $rootScope
- $sce
- $sceDelegate
- $templateCache
- $templateRequest
- $timeout
- $window
- $xhrFactory
- filter
- currency
- date
- filter
- json
- limitTo
- lowercase
- number
- orderBy
- uppercase
- auto
- ngAnimate
- ngAria
- ngComponentRouter
- ngCookies
-
ngMessageFormat
- ngMessages
-
ngMock
- object
- angular.mock
- service
- $animate
- $componentController
- $controller
- $exceptionHandler
- $flushPendingTasks
- $httpBackend
- $interval
- $log
- $timeout
- $verifyNoPendingTasks
- provider
- $exceptionHandlerProvider
- type
- $rootScope.Scope
- angular.mock.TzDate
- function
- angular.mock.dump
- angular.mock.inject
- angular.mock.module
- angular.mock.module.sharedInjector
- browserTrigger
- ngMockE2E
-
ngParseExt
- ngResource
- ngRoute
- ngSanitize
- ngTouch
$timeout
- - service in module ng
Overview
AngularJS's wrapper for window.setTimeout
. The fn
function is wrapped into a try/catch
block and delegates any exceptions to
$exceptionHandler service.
The return value of calling $timeout
is a promise, which will be resolved when
the delay has passed and the timeout function, if provided, is executed.
To cancel a timeout request, call $timeout.cancel(promise)
.
In tests you can use $timeout.flush()
to
synchronously flush the queue of deferred functions.
If you only want a promise that will be resolved after some specified delay
then you can call $timeout
without the fn
function.
Usage
$timeout([fn], [delay], [invokeApply], [Pass]);
Arguments
Param | Type | Details |
---|---|---|
fn
(optional)
|
function()= |
A function, whose execution should be delayed. |
delay
(optional)
|
number |
Delay in milliseconds. (default: 0) |
invokeApply
(optional)
|
boolean |
If set to (default: true) |
Pass
(optional)
|
* |
additional parameters to the executed function. |
Returns
Promise | Promise that will be resolved when the timeout is reached. The promise
will be resolved with the return value of the |
Methods
-
cancel([promise]);
Cancels a task associated with the
promise
. As a result of this, the promise will be resolved with a rejection.Parameters
Param Type Details promise (optional)Promise Promise returned by the
$timeout
function.Returns
boolean Returns
true
if the task hasn't executed yet and was successfully canceled.