Getting the ID from collection-repeat


#1

Hi, I’m currently building an Ionic app using firebase and angular fire. I’m trying to use collection-repeat instead of ng-repat but am struggling. I’m trying to replicate the following

Previously I have this using ng-repea (which works fine)t:

<ion-item ng-repeat="(id,delegate) in delegates" type="item-text-wrap" href="#/tab/delegate/{{id}}" class="item item-avatar">

This is what I have using collection-repeat (which isn’t giving me the id and therefore isn’t working):

<ion-item collection-repeat="(id,delegate) in delegates" href="#/tab/delegate/{{id}}"
                collection-item-width="'100%'"
                collection-item-height="80">

I’m still new to Ionic and Angular but would really love it if someone could tell me where I’m going wrong.

Thanks in advance


#2

If the array is coming from firebase I’m sure you can just use $id

<ion-item collection-repeat="delegate in delegates" href="#/tab/delegate/{{delegate.$id}}"
            collection-item-width="'100%'"
            collection-item-height="80">

#3

Awesome, that worked! Thank you. Where in the docs is this? I’d searched for ages and obviously missed it.


#4

No worries

Only reason I knew was because I’d played around with it last weekend and it stuck in my head :smiley: