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 lazy loading in angular?
What is angular cli json?
What is ngdobootstrap?
How do you interact between two components?
What is the difference between $scope and scope in angular?
Explain the different types of streams present in node.js?
what is the difference between one-way binding and two-way binding in angularjs?
Is angular still popular?
What is pipe function?
What is route in angular?
What is the difference between angular and react?
What is two way data binding in angularjs?
What is authguard?
What is the difference between [ngfor] and [ngforof]?
What are observables in angular?