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 |
Can you write both angular 1 and angular 2 codes in a single project?
Explain the difference between angular and angularjs?
What is the best way to declare and access a global variable in angular 2?
What is the purpose of a filter in angular?
Is angular front end or backend?
What is *ngfor directive used for?
What are the modules in angularjs?
What is a factory? What is the difference between service and factory?
Is it a good or bad practice to use angular js together with jquery?
Do you know scope in angularjs?
Explain route configuration?
How to set headers for every request in angular?