What is difference between $timeout and window.setTimeout in AngularJS?



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

Post New Answer

More AngularJS Interview Questions

What is chaining pipe?

0 Answers  


What is tap in angular?

0 Answers  


What Is The Difference Between One-Way Binding And Two-Way Binding?

0 Answers  


What is ngx bootstrap?

0 Answers  


What is angular expression? How do you differentiate between angular expressions and javascript expressions?

0 Answers  


What is jit and aot in angular?

0 Answers  


What is compilation in angular? What types of compilations are used in angular?

0 Answers  


Is react backend or frontend?

0 Answers  


How to define multiple restrict options on a directive in angularjs?

0 Answers  


In angular, describe how will you set, get and clear cookies?

0 Answers  


Is angular a mvc?

0 Answers  


What is ng-app, ng-init, and ng-model?

0 Answers  


Categories