AngularJS loading progress bar

前端 未结 5 1208
甜味超标
甜味超标 2020-12-30 10:26

When using AngularJS and doing a redirect using $location.path(\'/path\') the new page takes a while to load, especially on mobile.

Is there a way to ad

5条回答
  •  悲&欢浪女
    2020-12-30 10:42

    For a progress bar as YouTube has, you can take a look at ngprogress. Then just after the configuration of your app (for example), you can intercept route's events.

    And do something like:

    app.run(function($rootScope, ngProgress) {
      $rootScope.$on('$routeChangeStart', function() {
        ngProgress.start();
      });
    
      $rootScope.$on('$routeChangeSuccess', function() {
        ngProgress.complete();
      });
      // Do the same with $routeChangeError
    });
    

提交回复
热议问题