保留在AngularJS路径变化的滚动位置? [英] Retain scroll position on route change in AngularJS?

查看:130
本文介绍了保留在AngularJS路径变化的滚动位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例应用程序:<一href=\"http://angular.github.com/angular-phonecat/step-11/app/#/phones\">http://angular.github.com/angular-phonecat/step-11/app/#/phones

如果你选择了最后一个电话摩托罗拉的魅力,它会告诉你这款手机的详细信息。
当您导航回来你的浏览器,它重新加载数据和滚动是在顶部。

If you choose the last phone "Motorola charm" it will show you the details of the phone. When you navigate back with on your browser it reloads the data and scrolling is at the top.

什么是自动滚动到navigatin回来时留下的最好方法是什么?
而且,为什么角重装数据?

What is the best way to automatically scroll to where is was left when navigatin back? And also, why does angular reloads the data?

我有我的电脑上相同的角phonecat样本,我已经加入你滚动它加载更多数据的无限滚动。所以,我真的不希望用户再次或向下滚动30秒刷新50多个项目。

I have the same "angular-phonecat" sample on my computer and I have added an infinite scroll which loads more data as you scroll. So I really dont want the user to reload 50+ items again or scrolling down for 30 seconds.

推荐答案

我以前没有使用过它,但棱角分明有一个的 $ anchorScroll 服务。至于重新加载数据时,你可以使用 $ cacheFactory 缓存,或者存储数据在较高的范围。

I haven't used it before, but angular has a $anchorScroll service. As to reloading the data, you could cache it using $cacheFactory, or store the data on a higher scope.

这篇关于保留在AngularJS路径变化的滚动位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆