How to display stored item on html (Ionic storage)

Hello guys,

I have several items stored in ionic storage.
How can I display each of them on an html page?

Each item has key, value, id. They’re javascript data objects with several attributes.

I saved them using: ${ }, this.item);

and I know I can call them up using… but this doesn’t have documentation on how to display those items on a page.

I think I can use {{ }} or something similar to display them…

or is there a way to display storage item value from console.log? (value, key, index) => {
	console.log("This is the value", value)
	console.log("from the key", key)
	console.log("Index is" index)

works fine and it can load value of each item to console.log. I don’t know what’s problem with not being able to use the value on html page.

Please help.


Just assign the result of your storage.get() to an array and reflect that array in your template.


storageItems: Array<StorageItem>;

In constructor:

this.storageItems = [];


*ngFor="let item of storageItems"

Then populate from Storage

1 Like

The way i like is convert array of json into string and store it and during fetching convert string to json
Use json.parse() and json.stringify().
Then use ngfor in template

1 Like

Thanks for your reply!

I still have problem assigning the array correctly…
How would you assign this array to below example?
storageItems: Array

  ionViewDidLoad() {
   'item ' + => {

Sorry. I’m having hard time with ionic storage… any working example would be appreciated.

I tried it but it didn’t work.
How would you use json.stringfy() and parse() in my example?
When I use JSON.parse(value), I get an error message:

Uncaught SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)

What I would do is create a custom interface.

interface StorageItem {
 key: string,
 name: string

Or whatever your items entail.
Then I would follow along with my initial advice plus'item ' + => {
        this.storageItems = value;

If you’re just getting one item, just change

storageItems: Array<StorageItem>

storageItem: StorageItem;

1 Like

Yes, that’s like creating a model.
Thanks again! I will try it.
I think ionic storage is definitely the least developer friendly part of ionic. It’s like guess and try ill it works.

Yeah, its a lot of extra code to do effectively, but once you’re in the habit of creating interfaces for everything, it’ll change your life

I create them for absolutely everything now.

I have a provider in every app that solely holds interfaces.

Difference being that in a provider, add export. I.e.
export interface StorageItem {


1 Like

Its definitely up there.

1 Like

I’m working on the interface now and hopefully it works out.

Thanks again!

1 Like

No problem. Here’s where you would want to put that interface

import { Subject } from 'rxjs/Subject';
import { first, takeUntil } from 'rxjs/operators';

interface StorageItem {
 key: string,
 name: string

  selector: 'page-code-creation',
  templateUrl: 'code-creation.html',
1 Like

Thanks for everything but it’s still not working.

I’m loading the data provider in the first example on a item list html page using *ngFor.

<div *ngFor="let item of items">
<button (click)="saveToFav(item)">Save to Fav</button>

and here’s my item list page TS:

saveToFav(item) {`item ${ }`, JSON.stringify(this.item));
                  this.isFavorite = true; }

This saves item with its unique key id and all attributes…

and I created interface for items.

Here’ favorite page TS which I’m trying to load all items:

import { Component } from '@angular/core';

import { NavController, NavParams, Platform } from 'ionic-angular';
import { Storage } from '@ionic/storage';
import { Observable } from 'rxjs/Observable'
import {StorageItem } from './storageitem';
  selector: 'page-favourites',
  templateUrl: 'favourites.html'

export class FavouritesPage {

  isFavorite = false;
  submitted: boolean = false;
  item: any;
  key: any;
  storageItems: Array<StorageItem>;  
    public platform: Platform,
    private storage: Storage,
    public navCtrl: NavController,
    public navParams: NavParams,
  ) {

    this.storageItems = [];


  ionViewDidLoad() { (value) => {
      this.storageItems = value;


and favorite page html:

<div *ngFor="let item of storageItems">

I’m just error messages
ERROR Error: Error trying to diff ''. Only arrays and iterables are allowed

Any idea?

I can still see items stored in Chrome’s inspect -> application -> webSQL page.
and I can call items up in console too. So it’s saving items correctly… but they can’t be parsed.

Thanks in advance.

Using that method, youd want to push the items into storageItems. (value) =&gt; {

And may need to do (value: StorageItem) =&gt; {
1 Like


It’s working! thanks a lot Jaydz. (value) => {

this worked and I had to change *ngFor

<div *ngFor="let value of storedItems">

Now it’s showing a list of store value’s names.

You totally made my day! thanks

1 Like

Fantastic! Happy to have helped.

1 Like

@jaydz how would you remove a value in this set up?

removeFav(key) {;
this.isFavorite = false;

can’t remove a selected value from storage…

Is there anyone who knows how to delete an item from this set up?
I’m kinda stuck with this issue. splice() and pop() both didn’t work. ${ }} throws an error 'can’t read property of undefined