@DerpoRex wrote:
With this code I always get the error: All declarations of 'storage' must have identical modifiers'
import { BrowserModule } from '@angular/platform-browser'; import { ErrorHandler, NgModule } from '@angular/core'; import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular'; import { SplashScreen } from '@ionic-native/splash-screen'; import { StatusBar } from '@ionic-native/status-bar'; import { MyApp } from './app.component'; import { HomePage } from '../pages/home/home'; import {IonicStorageModule} from '@ionic/storage' @NgModule({ declarations: [ MyApp, HomePage ], imports: [ BrowserModule, IonicModule.forRoot(MyApp), IonicStorageModule.forRoot() ], bootstrap: [IonicApp], entryComponents: [ MyApp, HomePage ], providers: [ StatusBar, SplashScreen, {provide: ErrorHandler, useClass: IonicErrorHandler} ] }) export class AppModule {}import { Storage } from '@ionic/storage'; export class MyApp { constructor(private storage: Storage) { } storage.set('item1', 'item'); storage.get('item2').then((val) => { console.log('Your age is', val); }); }note: I got the code from the ionic docs
Posts: 1
Participants: 1