What is difference between $timeout and window.setTimeout in AngularJS?
Answer Posted / 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 |
Post New Answer View All Answers
Is it possible to have two ng-app directives for a single angular application?
What is activatedroute in routes?
Is angular easy to learn?
How to create angularjs filter which outputs html?
What is sse?
What is routerstatesnapshot in angular?
how to set a custom header on the request?
Format date time in angular js?
What are some security-related features built into the angular framework?
What is decorator in angular?
What is ngstyle and ngclass?
what is angular expression?
What is the difference between ngoninit and ngafterviewinit?
How to handle 'loading chunk failed' error in angularjs application?
Can we have nested controllers in AngularJS?