Retain scroll position after on back when using Angularjs $http cache true


#1

Hi there,

I know this is an old topic, but I cannot get it to work perfect in my case.
If I use a local var to store a large static list, when nav back to it it would auto scroll to my last position. but my list data are remotely loaded to the variable using Angular resource/$http, instead of writing a new service to cache the list data, I tried to use the $http cache: true option, this caches the list data and returns them instantly on back to the list, but the auto scroll doesn’t work.

Any idea?
Thanks


#2

you can save scroll position in rootScope while destroy scope

when load list finish, get scroll position from rootScope and scroll to position.


#3

Is there a way I can get the default auto scroll working with the cached data?

Thanks


#4

I’m using ionic-nav-bar and cache: true with my $resource queries, and it remembers the scroll position sometimes when I click back from a detail view and not others. I cannot replicate the problem consistently. Has anyone else run into this. I watched the network tab in chrome and it does not call the api again, so it is using cached data.


#5

So I fixed this by creating a “fake cache” in my rootScope combined with cache: true. Seems like the built in cache doesn’t cache enough or something.