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

Why decorators are used in angular?

0 Answers  


How to handling error and logging it?

0 Answers  


What is View in AngularJS?

1 Answers  


How many modules can be used in a single html page?

0 Answers  


List some new features comes with angular6

0 Answers  


What's new in angular 7?

0 Answers  


What is $location in angularjs?

0 Answers  


What is the factory method?

0 Answers  


Can you bootstrap multiple angular applications on same element?

0 Answers  


Explain uppercase filter?

0 Answers  


What is json web token in angularjs?

0 Answers  


what would you have in a shared module in angular 2?

0 Answers  


Categories