title: Ionic 2: Get index of each item in list and store it into Firebase
body: <p>I am currently developing an Ionic 2 Mobile Application. I have a list of items that I get from my Firebase using AngularFire2. I implemented a reorder function on the list. I would like to be able to store the index of the items in the lists and send it to my Firebase so that I can use the index to prioritise the items based on the user's preferences. Is there a way where I can do this? I tried to send 'indexes' to my Firebase but it didnt work.</p>
  
  <p>HTML:
          </p>
  
  <pre><code>      &lt;ion-list reorder="true" (ionItemReorder)="reorderItems($event)"&gt;
          &lt;ion-item *ngFor="let item of categories; let i = index;"&gt;
            {{i+1}}. {{item.name}}
          &lt;/ion-item&gt;
  
        &lt;/ion-list&gt;
      &lt;/ion-content&gt;
  </code></pre>
  
  <p>Typescript:</p>
  
  <pre><code>     export class ManageFavouritesPage {
        fireAuth: any;
        items: any;
        categories: any;
        categorykey: any;
  
        constructor(public navCtrl: NavController, public af: AngularFire, private toastCtrl: ToastController, public authData: AuthData) {
  
          let userid = this.authData.getID();
          this.items = af.database.list(`/users/${userid}/favourites`)
            .subscribe(data =&gt; this.categories = data)  
        }
  
  
        reorderItems(indexes) {
          let element = this.categories[indexes.from];
          let element2 = this.categories[indexes.to].$key;
          this.categories.splice(indexes.from, 1);
          this.categories.splice(indexes.to, 0, element);
          let userid = this.authData.getID();
          this.items = this.af.database.object(`users/${userid}/favourites/${element2}`).update( {priority: indexes.to});
  
       }
       }
  </code></pre>