In one of my Angular HTML pages, there seems to be a slight issue. Everything is working smoothly - the code, the directives (except for "ng-show" which never seems to work, but that's not the main concern here).
However, when I have a button click event with heavy code running on it (using ng-click
), the page freezes during execution. This is expected, but what I really want is to display an image while the code is executing. Unfortunately, it appears that nothing gets updated on the page during the code block (although everything updates perfectly after the code finishes).
Is there a way to "refresh" the Angular HTML during the execution of the code within the "ng-click" function?
I've attempted using "$scope.apply()" and "$scope.digest()", but they lead to some strange errors in the console...
EDIT
Thanks to the helpful responses below: It turns out the errors were occurring because the "apply/digest" was already in progress. By utilizing the asynchronous methods suggested, I can now use "apply" without any issues.