In AngularJS, $interval is used to handle some things intermittently.
The most commonly used are:
var app = ("app",[]); ("AppCtrl", function($q. $interval){ var timer = $interval(function(){ },100); (success); function success(){ ("done"); } })
Above, do one thing every 100 milliseconds, all of which were calling the then function last night. That is, $interval provides a callback function.
Can you control the number of times you do things?
--OK。 var timer = $interval(function(){},100,10);
Above, the last actual parameter 10 is the limit number.
What other callback functions are there besides calling after everything is over?
--Some also include the callback function when the event is called and the callback function when the error occurs.
var timer = $interval(function(){},100, 10); (success, error, notify); function success(){ ("done"); } function error(){ ("error"); } function notify(){ ("Updated every time"); }
Can I cancel the $interval service?
--pass$(timer); var timer = $interval(function(){},100, 10); = function(){ $(timer); }
The above is a detailed explanation of the usage of $interval in AngularJS, and I hope it will be helpful to everyone.