Angularjs: How to display loading-icon when using 'resolve' in $routeProvider?

后端 未结 6 508

The following code reads via a service and shows on the web page a list of \'page\' objects for a specific \'page category\' (string). Using the resolve object property in $

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 19:59

    Not exactly sure whether this would work in your code as you have $resource integration. But it may be worth to look into angular events: $routeChangeStart and $routeChangeSuccess.

    in html:

     loading the view... 
    

    in controller (which defines the scope of the html above):

    $scope.isViewLoading = false;
    $scope.$on('$routeChangeStart', function() {
      $scope.isViewLoading = true;
    });
    $scope.$on('$routeChangeSuccess', function() {
      $scope.isViewLoading = false;
    });
    $scope.$on('$routeChangeError', function() {
      $scope.isViewLoading = false;
    });
    

提交回复
热议问题