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 data binding in angular?
Can you please explain what is testability like in angular?
Can I learn angular without knowing javascript?
What is service in angularjs with example?
What is eventemitter in angular?
What is directive in angular?
What is angular base elements?
What are differences between angular 2 and angular 1?
What is tsconfig json in angulr 2?
What is shadow dom and virtual dom?
What filters to use for photography?
What is scope in AngularJS?