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 |
How to write if else and then conditions in angular 4?
What is the use of ngafterviewinit?
Define the features of angularjs.
What is $ digest?
What is Model in AngularJS?
What is the main thing that you would need to change if you were migrating from angularjs 1.4 to angularjs?
How are you managing cookie in AngularJS
What is a service? How will you create a custom service?
Difference between angular 2, 4, 5, 6, &7?
How logs are maintained in angularjs?
What are the difference between renderer and elementref in angular 2?
What is a php developer salary?