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 are the symbols used in one way and two ways data binding?
What is event binding in angular?
What is the factory method?
What is ngoninit ()?
How to assign alternate class to rows in angular js?
How to import css using system import?
Is angularjs extensible?
How to get user input from the $event object?
What is a decorator function?
What are the cookies in angular 2?
What is a service? How will you create a custom service?
Distinguish between angularjs and javascript expressions.