What do I need to do to update the scope variable in the UI on every iteration of the loop in this example?
JS
var q = 100;
while ( q > 0 ) {
$scope.someThing = q;
q--;
}
HTML
{{someThing}}
I thought I was on to something with the following but it isn't working. All I see is the final result, not each iteration.
var q = 1000;
while ( q > 0 ) {
$scope.$apply(function () {
$scope.someThing = q;
q--;
});
}
--Edit--
Thanks for the suggestions on interval/timeout. I think I understand why this is needed now. But I was hoping I could "callback" the redraw somehow so the loop still runs as fast as possible. Is there a simple way to achieve that?
$timeoutbasically you would need to make it async. loop runs synchronously. SO your loop completes running digest cycle happens and view gets updated with the result.