top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is difference between $interval and window. setInterval in AngularJS?

0 votes
529 views
What is difference between $interval and window. setInterval in AngularJS?
posted Nov 18, 2017 by Jayshree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

$interval is an Angular service which wraps the browser's window. setInterval() function. It is also used
to call a JavaScript function repeatedly within a time interval.

var app = angular.module("app", []);
app.controller("MyController", function ($scope, $interval) {
 $interval(callAtInterval, 3000);
});
function callAtInterval() {
 console.log("Interval occurred");
}
answer Nov 18, 2017 by Shivaranjini
...