On the remarkably brief AngularJS $timeout documentation page, the 'delay' argument is stated as optional. When using $timeout without specifying a delay, I note that a delay is still applied.
Can anyone tell me how much time is allotted for the delay when the argument is left implicit?
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.
Angular $timeout is a wrapper written for window. setTimeout in form of a try catch block which throws exceptions via $exceptionHandler service. $timeout accepts the function to be delayed, delay time, a boolean to invoke $. apply and parameters to be passed to the function.
setTimeout() The global setTimeout() method sets a timer which executes a function or specified piece of code once the timer expires.
AngularJS Scope The scope is the binding part between the HTML (view) and the JavaScript (controller). The scope is an object with the available properties and methods. The scope is available for both the view and the controller.
When $timeout
delay is omitted, it defaults to 0
. However, the block of code contained in it is executed after the DOM has been manipulated by Angular. See response to AngularJS $evalAsync vs $timeout
My understanding is that a delay of '0' means that it will be picked-up as part of the next run of the event loop. That's an especially short but indeterminate amount of time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With