# Can I use anchorScroll with collection-repeat?

**URL:** <https://forum.ionicframework.com/t/can-i-use-anchorscroll-with-collection-repeat/4500>\
**Category:** ionic-v1\
**Created:** [May 20, 2014, 12:39am UTC](https://forum.ionicframework.com/t/can-i-use-anchorscroll-with-collection-repeat/4500 "2014-05-20T00:39:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CaryyLorrk](https://avatars.discourse-cdn.com/v4/letter/c/2bfe46/32.png) [@CaryyLorrk](https://forum.ionicframework.com/u/CaryyLorrk)\
**Post date:** [May 20, 2014, 12:39am UTC](https://forum.ionicframework.com/t/can-i-use-anchorscroll-with-collection-repeat/4500/1 "2014-05-20T00:39:48Z")

</div>

I try to use anchorScroll with collection-repeat.  
this is my code.

```
<ul class=list" id="downloadList" animation="slide-left-right">
    <a id="{{pack.packageId}}"
         collection-repeat="pack in packs | filter:downloadText
         collection-item-width="'100%'"
         collection-height="70"
         style="width:100%"
         class="item item-avatar"
         ng-href="#/app/download/{{pack.packageId}}">
             <img ng-src="{{...}}" alt="{{pack.packageId}}">
             <h2>{{pack.packageId}}</h2>
             <h3>{{pack.title[i8n] || pack.title.en}}</h3>
    </a>
</ul>

```

and try to scroll to the id

```
$location.hash(id);
$ionicScrollDelegate.anchorScroll());

```

But failed. If i replace collection-repeat with ng-repeat, it works.  
Is it impossble to locate the position with collection-repeat?

update:  
I use scrollBy and getElementId to find the ID.  
But there are some problem.

1. It’s too slow!
2. $ionicScrollDelegate.scrolBy don’t have callback function. I need a magic setTimeout value to delay it.  
Any better solution?

---

<div class="post-metadata">

**Author:** ![miguel](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@miguel](https://forum.ionicframework.com/u/miguel)\
**Post date:** [August 15, 2014, 2:32pm UTC](https://forum.ionicframework.com/t/can-i-use-anchorscroll-with-collection-repeat/4500/2 "2014-08-15T14:32:18Z")

</div>

some issue here, any updates?

---

<div class="post-metadata">

**Author:** ![ronycohen](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ronycohen/32/7982_2.png) [@ronycohen](https://forum.ionicframework.com/u/ronycohen)\
**Post date:** [December 13, 2014, 5:26pm UTC](https://forum.ionicframework.com/t/can-i-use-anchorscroll-with-collection-repeat/4500/3 "2014-12-13T17:26:30Z")

</div>

Same for me.  
Issues with collectionRepeat not working with anchorScroll.

```
<ion-content has-header="true" delegate-handle="EventsScroll">
	<div class="list collection-list">
		<div class="item collection-item item-icon-right wa_middle"
			collection-repeat="item in listEchanges"
			collection-item-height="getItemHeight(item)"
			collection-item-width="'100%'"
			id="{{item.id}}" >
			<div class="inline-block">
				<div>{{item.date || item.displayName }}</div>
			</div>
		</div>
	</div>
</ion-content>

```

I define an ID with : id="{{[item.id](http://item.id)}}" and I’m looking for the id="0"  
On the controller :

```
$scope.scrollTo = function (id) {
   $location.hash(id);
   var delegateHandle = $ionicScrollDelegate.$getByHandle('EventsScroll');
   delegateHandle.anchorScroll(id);
};

$timeout(function() {
	// $ionicScrollDelegate.$getByHandle('EventsScroll').scrollBottom(); // WORKING
	$scope.scrollTo('0'); // **NOT WORKING and I have an id="0" in my DOM**
}, 2000);
```

---

<div class="post-metadata">

**Author:** ![ronycohen](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ronycohen/32/7982_2.png) [@ronycohen](https://forum.ionicframework.com/u/ronycohen)\
**Post date:** [December 13, 2014, 6:25pm UTC](https://forum.ionicframework.com/t/can-i-use-anchorscroll-with-collection-repeat/4500/4 "2014-12-13T18:25:36Z")

</div>

> [@CaryyLorrk](#):
>
> update:

Can you give us an example with what you explained in your update ?  
thank you.
