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 scope in javascript?
How to use primeng in angular 4?
How to validate password and confirm password in angular 4?
What is data binding in angularjs and what is the difference between one-way and two-way binding?
What are ngModel and how do we represent it?
What are types in typescript?
How to starting angular 4 apps using ionic 3 cli commands?
Do you know scope in angularjs?
What is a pure pipe?
What is the languages that you can use to build angular 2 application?
Explain data binding in angular js.
How to upgrade angular 7 to 8?