Thomas Degroot
Thomas Degroot

Reputation: 524

How do I start the index array after 1 in an ionic 4 App sqlite db

I am looping thought the the sqlite db with ionic storage using this code

ts

listKeys() {
  this.storage.keys().then((k) => {
    console.table(k);
    this.loop = k;
    console.log("key value", this.loop);
  });
}

Here is what I get

list of keys

I use this html to view my list

  <ion-item-sliding *ngFor="let list of loop; index as i ">
    <ion-item>
        {{loop[i]}}
    </ion-item>
    <ion-item-options side="end">
      <ion-item-option (click)="deleteKeyValue( loop[i] )" color="danger">
        <ion-icon slot="icon-only" name="trash"></ion-icon>
      </ion-item-option>
    </ion-item-options>
  </ion-item-sliding>

I wish to start the loop after Index 1. I have tried "index as i > 1 " and loop[ i > 1 ]. of course neither work. Any help would be greatly appreciated.

Upvotes: 0

Views: 702

Answers (2)

Thomas Degroot
Thomas Degroot

Reputation: 524

Here is the final code after implementing the answer and correcting my issues with looping.

<ion-list lines="inset">
  <ion-item-divider>
    <ion-label>
      List of Audits
    </ion-label>
  </ion-item-divider>
 <ion-item-sliding *ngFor="let i of loop | slice:2">
    <ion-item>
        {{i}}
    </ion-item>
    <ion-item-options side="end">
      <ion-item-option (click)="deleteKeyValue( i )" color="danger">
        <ion-icon slot="icon-only" name="trash"></ion-icon>
      </ion-item-option>
    </ion-item-options>
  </ion-item-sliding>
</ion-list> 

Upvotes: 0

nll_ptr
nll_ptr

Reputation: 881

Use the SlicePipe https://angular.io/api/common/SlicePipe

<ion-item-sliding *ngFor="let list of loop | slice:2; index as i ">

Upvotes: 1

Related Questions