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
Explain how we can create module and using it in AngularJS?
Mention what are the characteristics of “scope”?
What is pure pipe in angular?
What is the singleton pattern?
How many types of ngmodule?
How to using looping through a collection for each item in angular js?
What does three dots mean in angular?
Explain ng-controller directive ?
What is the use of a double-click event in angularjs?
What are the types of linking function?
What is angular @ routeparams?
Explain AngularJS scope life-cycle?
How prevents html dom based cross site scripting (xss) attacks?
What is shadow dom? How is it helping angular 2 to perform better?
What is directives in angular 2?