In app.module.ts
import { IonicStorageModule } from ‘@ionic/storage’;
@NgModule({
declarations: [
MyApp,
StarterPage,
HomePage,
InvitePage
],
imports: [
IonicModule.forRoot(MyApp, {
modalEnter: ‘modal-slide-in’,
modalLeave: ‘modal-slide-out’,
pageTransition: ‘ios-transition’
}),
IonicStorageModule.forRoot(),
CloudModule.forRoot(cloudSettings)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
StarterPage,
HomePage,
InvitePage
],
providers: [
DataService,
{ provide: ErrorHandler, useClass: IonicErrorHandler }
]
in providers/data-service.ts
import { Storage } from ‘@ionic/storage’;
constructor(
public storage: Storage,
public alertCtrl: AlertController,
public toastCtrl: ToastController
) {
// console.log(‘Hello DataService Provider’);
storage.ready().then(() => {
});
}
setValue(key: string, value: any) {
this.storage.set(key, value);
return true;
}
getValue(key: string) {
this.storage.get(key).then((val) => {
return val;
});
}
when i am trying to get it returns null