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 is chaining pipe?
What is tap in angular?
What Is The Difference Between One-Way Binding And Two-Way Binding?
What is ngx bootstrap?
What is angular expression? How do you differentiate between angular expressions and javascript expressions?
What is jit and aot in angular?
What is compilation in angular? What types of compilations are used in angular?
Is react backend or frontend?
How to define multiple restrict options on a directive in angularjs?
In angular, describe how will you set, get and clear cookies?
Is angular a mvc?
What is ng-app, ng-init, and ng-model?