当使用 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/