What is wrong in my storage implementation?


#1

i’m trying to save data in local storage in ionic 2 app so i import the storage and did exactly like i saw in the website and it not save the data in the storage

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

import { NavController,NavParams,LoadingController,AlertController,ViewController } from ‘ionic-angular’;
import { Facebook } from ‘ionic-native’;

//import pages
import {LoginPage} from “…/…/pages/login/login”;
import {User} from '…/…/models/user’
import { Storage} from ‘@ionic/storage’;
//import provider
import { ProfileData } from ‘…/…/providers/profile-data’;
import { NotesData } from ‘…/…/providers/notes-data’;

import firebase from 'firebase’
import {AddNote} from “…/add-note/add-note”;

@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})

export class HomePage {

pages: Array<{title: string, component: any}>;

constructor(public navCtrl: NavController,public storage:Storage) {
this.storage.set(‘photo’,“123”); //for check
}

photo of the inspect with chrome developer

i don’t see any key of photo as i set it… why is that?


#2

I’m not able to get storage to work either. Are there errors in your javascript console?


#3

No… i dont see any error in console


#4

Did you import storage in app.module.ts ?

import { Storage } from ‘@ionic/storage’;

and inside providers:[Storage, …]