Apply loading spinner during ui-router resolve

后端 未结 6 1219
面向向阳花
面向向阳花 2020-12-22 17:34

resolve property of $routeProvider allows to execute some jobs BEFORE corresponding view is rendered.

What if I want to display a spinner

6条回答
  •  暖寄归人
    2020-12-22 18:15

    i think this is pretty neat

    app.run(['$rootScope', '$state',function($rootScope, $state){
    
      $rootScope.$on('$stateChangeStart',function(){
          $rootScope.stateIsLoading = true;
     });
    
    
      $rootScope.$on('$stateChangeSuccess',function(){
          $rootScope.stateIsLoading = false;
     });
    
    }]);
    

    and then on view

    Loading.

提交回复
热议问题