My current situation involves a view that takes around 3 seconds to render. During this time, users are left waiting with no indication of progress on the page. I attempted to implement a spinner for visual feedback, but unfortunately, it remains stuck and does not spin as intended. It seems that the browser is waiting for the JavaScript code to finish executing before allowing the spinner to display properly. If the issue stems from the fact that the JavaScript code runs for 3 seconds, restricting browser control, how can I optimize this process? Without the framework, I could break my code into smaller segments and execute them with timeouts, but I am unsure how to achieve this within Angular during its linking phase.
UPDATE:
To illustrate the problem, I have provided a jsfiddle. The spinner fails to spin when the execution remains within a loop.
<img src="http://content.markitcdn.com/corporate/ResourceManager/9Iy-xMz_zHH-zXFAlhM-KA2/d/f/635151312565356632/Content/Images/Icons/General/spinner2.gif" alt="">
<script>
console.log('entering loop')
for (var i=0;i<300000000;i++) {}
console.log('leaving loop')
</script>