0

In my AngularJS app, I am displaying a loading icon to the user until all the content has loaded. I have two conditions in the controller which change once content has loaded, like so:

function form1200questionnaireCtrl(){
    vm.loading = true;
    vm.patentsLoaded = true;

    angular.element(function () {
        vm.loading = false;
        vm.patentsLoaded = true;
        console.log('should hit', vm.loading, vm.patentsLoaded)
    });
} 

<div data-ng-show="$ctrl.loading" >
    <img src="assets/imgs/icons/spinner-loader.gif">
</div>
<div data-ng-show="$ctrl.patentsLoaded" class="animate-show">  
    //all content 
</div>

My issue is that the values of both vm.loading and vm.patentsLoaded change value as I have logged it into the console, but the loading gif displays for around 10-15 seconds before hiding and the content displaying.

Question

Why is the view not picking up the change in the scope immediately with ng-show?

Patrick McDermott
  • 1,220
  • 1
  • 15
  • 30

0 Answers0