I have an $interval
that calls a certain number of times.
When the interval has finished running, I want it to call a final reset function. How can I do this?
ie.
$scope.clickme = function() {
var i = 0;
function lerp() {
alert(i++);
}
function fin(){ //how do I call this function?
alert ("all done!")
}
$interval(lerp, 500, 5);
};
JSFiddle: http://jsfiddle.net/h4cn32e6/1/
The return value of registering an interval function is a promise. This promise will be notified upon each tick of the interval, and will be resolved after count iterations
So:
$interval(lerp, 500, 5).then(fin);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With