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 the need for typescript in angular 2?
Differentiate between Components and Directives in Angular 5?
Does AngularJS support MVC?
Explain how does angularjs implement two-way binding?
What is single page application in angularjs?
What is the role of ng-app, ng-init and ng-model directives?
What's new features in angular 5?
What is lazy loading angularjs?
How to use ng-show and ng-hide in angular js?
What is pipe in networking?
What is angular good for?
What is Component in Angular Terminology?