How can I make sure the function runAfterLoopFinishes() runs after the $interval has finished? Right now it runs immediately after loop is first defined.
var loop = $interval(function () {
// Do something great 10 times
}, 1000, 10);
// To run after looping
runAfterLoopFinishes();
$interval returns a promise.
var loop = $interval(function () {
// Do something great 10 times
}, 1000, 10);
loop.then(function(){
// To run after looping
runAfterLoopFinishes();
}
An $interval promise will be notified after each iteration, but only resolve after the last.
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