I have been struggling for hours to find a solution without any success. In my angularjs application, I am trying to implement a loading spinner that will display until the page is fully loaded or rendered, especially during state transitions where there is a delay in response. The issue is that even though the click event is registered, no visible feedback is shown to the user indicating whether the page is still loading or not. My application makes ajax calls when the controller is executed. I have attempted various approaches:
Using
$stateChangeStart
and$viewContentLoaded
. This method works well when the views are initially loaded but triggers too early during subsequent state changes due to template caching.Creating a directive with
$timeout
. Initially this worked when attached to thebody
element, however, it does not get called again when switching between states because of nested views/controllers. When attached to theui-view
element, it fires too early.
Are there any other alternatives? Am I missing something important? Is this even achievable?
Thank you