I have a list that loops through keys of a SQlite db using ionic storage. I use the Angular slice to omit the first to rows. I also want to omit a row with the name of a_images. I would prefer not to use a pipe for a single text item. If I am I forced to use a pipe, what would the basic code inside the pipe even look like for a single text item?
html
<ion-list lines="inset">
<ion-item *ngFor="let i of loop | slice:2">
<ion-label>{{i}}</ion-label>
<ion-button fill="outline" color="success" slot="end" (click)="openKeyValue( i )">Open</ion-button>
</ion-item>
</ion-list>
ts
// Traverse key/value pairs
listKeys() {
this.storage.keys().then((k) => {
console.table(k);
this.loop = k;
console.log("key value", this.loop);
});
}
You can put special case code into your loop with an *ngIf
.
Something like:
<ion-list lines="inset">
<ng-container *ngFor="let i of loop | slice:2">
<ion-item *ngIf="i !== 'a_images'">
<ion-label>{{i}}</ion-label>;
<ion-button fill="outline" color="success" slot="end" (click)="openKeyValue( i )">Open</ion-button>
</ion-item>
</ng-container>
</ion-list>
Alternatively you can pre-filter your data before you assign it to this.loop
with something like:
this.loop = this.loop.filter(key => key !== 'a_images');