What is difference between $timeout and window.setTimeout in AngularJS?
Answer / pintu
$timeout is an Angular service which wraps the browser's window.setTimeout() function into a try/catch block and delegates any exceptions to $exceptionHandler service. It is used to call a JavaScript function after a given time delay. The $timeout service only schedules a single call to the function.
var app = angular.module("app", []);
app.controller("MyController", function ($scope, $timeout) {
$timeout(callAtTimeout, 1000);
});
function callAtTimeout() {
console.log("Timeout occurred");
}
| Is This Answer Correct ? | 0 Yes | 0 No |
What do you know about injector?
What is angular model?
Explain filter filter angularjs?
What is * ngfor?
How to enable html5 mode in angular 1.x?
Does AngularJS support MVC?
How can you create a decorator in angular?
Can angular run without node?
What is $timeout in angularjs?
What is react vs angular?
What is template angular 2? Why use?
Explain e2e testing of angular js applications.