AngularJS加载进度条

标签 angularjs

当使用 AngularJS 并使用 $location.path('/path') 进行重定向时,新页面需要一段时间才能加载,尤其是在移动设备上。

有没有办法添加加载进度条?也许 YouTube 之类的有?

最佳答案

对于 YouTube 那样的进度条,您可以查看 ngprogress 。然后,在配置您的应用程序之后(例如),您可以 intercept route's events .

并执行以下操作:

app.run(function($rootScope, ngProgress) {
  $rootScope.$on('$routeChangeStart', function() {
    ngProgress.start();
  });

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

关于AngularJS加载进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19779917/

相关文章:

angularjs - 通过最新输入加载 json - Angularjs

angularjs - 在下拉框中自动选择已保存的值

javascript - Angular - 我应该使用局部变量还是 this.variable

css - AngularJS:使用 css 媒体查询调整屏幕大小

javascript - IE-11 : Object doesn't support property or method 'parseInt'

javascript - 延迟 AngularJS 路由更改直到模型加载以防止闪烁

javascript - AngularJS - 在访问 DOM 的自定义指令中设置 Controller 的 $scope 变量

javascript - 如何在 ag-grid 列标题中嵌入 dropDown HTML?

javascript - 如何对由3个点组成的字符串数字进行排序?

javascript - Angular 和推特 REST API