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 |
Why decorators are used in angular?
How to handling error and logging it?
What is View in AngularJS?
How many modules can be used in a single html page?
List some new features comes with angular6
What's new in angular 7?
What is $location in angularjs?
What is the factory method?
Can you bootstrap multiple angular applications on same element?
Explain uppercase filter?
What is json web token in angularjs?
what would you have in a shared module in angular 2?