Collection-repeat and rememberScrollPosition

I am trying to make collection repeat remember it s scrolling position after navigating to a detail view and back…
Is there a simple codepen for that? should it work out of the box?


Should work right out of the box. Collection repeat is similar to using ng-repeat, just highly optimized.

@mhartington could you please provide some codepen which remembers the scroll position in the collection repeat.


Yeah, here you go

Awesome simple example @mhartington many thanks!

Any tips for adjusting that output to have the text on the right of the image instead of underneath?

So it looks more like:

Thanks again!

You use the class item-thumbnail-left

  <a class="item my-item item-thumbnail-left"
    collection-repeat="pet in pets"
     ui-sref="detail({petsId: })">
    <img ng-src="{{55 + ($index % 10)}}">

The codepen has ben updated to reflect this.

1 Like

Thanks very much, that’s a great help :slight_smile:

i just changed your example so that the service to get the data uses a promise.

the scroll position is not remembered in that case.
What is the best way to handle that?


Set delegate-handle to HTML ion-content, and in JS get delegate from the handle.
And when setting $scope.pets, call scrollToRememberedPosition of the delegate.
Check the source below: