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
What is two way data binding angularjs?
List some inbuilt pipes available in angular
What is scope hierarchy in angularjs?
What is the difference between activatedroute and activatedroutesnapshot?
What is activatedroute snapshot?
What is hoisting in js?
What does ng stands for in angular?
What is ngmodel in angular?
What are directives? How to create and use custom directive in angularjs.
Which components can be injected as a dependency in angular js?
Can we have nested controllers in AngularJS?
What is the role of $routeprovider in angularjs?
Explain bazel?
Is angular harder than react?
When first angularjs was released?