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 sequence of Angular Lifecycle Hooks?
What is lazy loading images?
What is scope in AngularJS?
What are the concept of scope hierarchy? Tell me how many scope can an application have?
How do you define a transition between two states in angular?
Explain the concept of hierarchy?
What is the traceur compiler?
What types of pipes are supported in angular 2?
How will you display different images based on the status being red, amber, or green?
What is module in angular?
Can I use angularjs with php?
How would you update angular 6 to angular 7?