间隔运行完毕后,我想让它调用最终的复位功能.我怎样才能做到这一点?
即.
$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
所以:
$interval(lerp,5).then(fin);