In my application, I store data in a string.
To convert the data into arrays, I use JSON.parse.
this.items = JSON.parse(todos);
On the results page, I display my arrays as follows: Array1 Array2 Array3
However, I have noticed that the delete button after each array only removes the item from the list and not from local storage. Is there something wrong with my implementation?
This is the code for list.html:
<ion-item-sliding *ngFor="let item of items">
<ion-item>
<p>{{item.amount}}tk X {{item.class}} / {{item.size}}ml / {{item.proof}}%</p>
</ion-item>
<ion-item-options>
<button danger (click)="removePost(item)">
<ion-icon name="trash"></ion-icon>Remove
</button>
</ion-item-options>
</ion-item-sliding>
And this is list.ts:
removePost(item){
let index = this.items.indexOf(item);
if(index > -1){
this.items.splice(index, 1); // works
this.storage.remove(this.items[index]); // doesn't work
}
}