title: Uncaught Error: Can't resolve all parameters for StorageService
body: <p>I am trying to implement sql storage in an ionic cordova app. i followed the tutorial here: <a href="https://ionicacademy.com/ionic-storage-crud-operations/" rel="nofollow noreferrer">https://ionicacademy.com/ionic-storage-crud-operations/</a>
  and the ionic pages here: <a href="https://ionicframework.com/docs/building/storage" rel="nofollow noreferrer">https://ionicframework.com/docs/building/storage</a></p>
  
  <p>I am getting Uncaught Error: </p>
  
  <pre><code>Can't resolve all parameters for StorageService: (?).
      at syntaxError (vendor.js:84831)
      at CompileMetadataResolver._getDependenciesMetadata (vendor.js:100051)
      at CompileMetadataResolver._getTypeMetadata (vendor.js:99886)
      at CompileMetadataResolver._getInjectableMetadata (vendor.js:99866)
      at CompileMetadataResolver.getProviderMetadata (vendor.js:100226)
      at vendor.js:100137
      at Array.forEach (&lt;anonymous&gt;)
      at CompileMetadataResolver._getProvidersMetadata (vendor.js:100097)
      at CompileMetadataResolver.getNgModuleMetadata (vendor.js:99665)
      at JitCompiler._loadModules (vendor.js:118758)
  </code></pre>
  
  <p>My app.module.ts:</p>
  
  <pre><code>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';
  
  //**************** Added Modules
  import { HttpModule } from '@angular/http';
  import { HttpClientModule } from '@angular/common/http';
  import { IonicStorageModule } from '@ionic/storage/';
  import { InAppBrowser } from '@ionic-native/in-app-browser';
  import { EmailComposer } from '@ionic-native/email-composer';
  
  //**************** Created Pages
  import { HomePage } from '../pages/home/home';
  import { DemographicsPage } from '../pages/demographics/demographics';
  import { AuthPage } from '../pages/auth/auth';
  import { WeightPage } from '../pages/weight/weight';
  
  //**************** Created Service
  import { AuthService } from '../services/auth.service';
  import { RefreshTokenService } from '../services/refreshToken.service';
  import { FormEncoderService } from '../services/formEncoder.service';
  import { DecodeLoinc } from '../services/decodeLoinc.service';
  import { AddWeightPage } from '../pages/add-weight/add-weight';
  import { StorageService } from '../services/storage.service';
  
  @NgModule({
    declarations: [
      MyApp,
      HomePage,
      DemographicsPage,
      AuthPage,
      WeightPage,
      AddWeightPage
    ],
    imports: [
      BrowserModule,
      IonicModule.forRoot(MyApp),
      HttpModule,
      HttpClientModule,
      IonicStorageModule.forRoot({})
    ],
    bootstrap: [IonicApp],
    entryComponents: [
      MyApp,
      HomePage,
      DemographicsPage,
      AuthPage,
      WeightPage,
      AddWeightPage
    ],
    providers: [
      StatusBar,
      SplashScreen,
      AuthService,
      RefreshTokenService,
      FormEncoderService,
      StorageService,
      DecodeLoinc,
      InAppBrowser,
      EmailComposer,
      { provide: ErrorHandler, useClass: IonicErrorHandler }
    ]
  })
  export class AppModule {}
  </code></pre>
  
  <p>and my storage.service.ts</p>
  
  <pre><code>import { Storage } from '@ionic/storage';
  
  export interface Item {
    id: number;
    weight: number;
  }
  
  const WEIGHTS_KEY = 'my-weights';
  
  export class StorageService {
    constructor(private storage: Storage) {}
  
    //create
    addItem(item: Item): Promise&lt;any&gt; {
      return this.storage.get(WEIGHTS_KEY).then((items: Item[]) =&gt; {
        if (items) {
          items.push(item);
          return this.storage.set(WEIGHTS_KEY, items);
        } else {
          return this.storage.set(WEIGHTS_KEY, [item]);
        }
      });
    }
  
    //read
    getItems(): Promise&lt;Item[]&gt; {
      return this.storage.get(WEIGHTS_KEY);
    }
  }
  </code></pre>
  
  <p>and the service is implemented here:</p>
  
  <pre><code>import { Component } from '@angular/core';
  import { ViewController, NavController } from 'ionic-angular';
  import { NgForm } from '@angular/forms';
  import { EmailComposer } from '@ionic-native/email-composer';
  import { WeightPage } from '../weight/weight';
  import { StorageService, Item } from '../../services/storage.service';
  
  @Component({
    selector: 'page-add-weight',
    templateUrl: 'add-weight.html'
  })
  export class AddWeightPage {
    private enteredWt: number;
    private subject = 'New Patient Weight';
    private body = '';
    private to = 'mfhamid@cmh.edu';
    emailed: boolean = false;
    items: Item[] = [];
    newItem: Item = &lt;Item&gt;{};
  
    constructor(
      private viewCrtl: ViewController,
      private emailComposer: EmailComposer,
      private navCtrl: NavController,
      private storageService: StorageService
    ) {}
  
    onAddWeight(form: NgForm) {
      ..........
    }
  
    saveWeight() {
      this.newItem.id = new Date().getTime();
      this.newItem.weight = this.enteredWt;
      // var date = new Date().getTime().toString();
  
      this.storageService.addItem(this.newItem).then(item =&gt; {
        this.newItem = &lt;Item&gt;{};
      });
    }
  
    EmailWeight() {
      ........
    }
  
    onClose() {
      .........
    }
  }
  </code></pre>
  
  <p>I also tried to configure the database following the ionic page without success:</p>
  
  <pre><code>imports: [
      IonicStorageModule.forRoot({
        name: '__mydb',
  driverOrder: ['indexeddb', 'sqlite', 'websql']
      })
    ],
  </code></pre>
  
  <p>config file:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"&gt;
      &lt;name&gt;weaigheasy&lt;/name&gt;
      &lt;description&gt;An awesome Ionic/Cordova app.&lt;/description&gt;
      &lt;author email="hi@ionicframework" href="http://ionicframework.com/"&gt;Ionic Framework Team&lt;/author&gt;
      &lt;content src="index.html" /&gt;
      &lt;access origin="*" /&gt;
      &lt;allow-intent href="http://*/*" /&gt;
      &lt;allow-intent href="https://*/*" /&gt;
      &lt;allow-intent href="tel:*" /&gt;
      &lt;allow-intent href="sms:*" /&gt;
      &lt;allow-intent href="mailto:*" /&gt;
      &lt;allow-intent href="geo:*" /&gt;
      &lt;allow-intent href="http://localhost/*" /&gt;
      &lt;preference name="ScrollEnabled" value="false" /&gt;
      &lt;preference name="android-minSdkVersion" value="19" /&gt;
      &lt;preference name="BackupWebStorage" value="none" /&gt;
      &lt;preference name="SplashMaintainAspectRatio" value="true" /&gt;
      &lt;preference name="FadeSplashScreenDuration" value="300" /&gt;
      &lt;preference name="SplashShowOnlyFirstTime" value="false" /&gt;
      &lt;preference name="SplashScreen" value="screen" /&gt;
      &lt;preference name="SplashScreenDelay" value="3000" /&gt;
      &lt;platform name="android"&gt;
          &lt;allow-intent href="market:*" /&gt;
          &lt;icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" /&gt;
          &lt;icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" /&gt;
          &lt;icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" /&gt;
          &lt;icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" /&gt;
          &lt;icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" /&gt;
          &lt;icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" /&gt;
          &lt;splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" /&gt;
          &lt;splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" /&gt;
          &lt;splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" /&gt;
          &lt;splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" /&gt;
          &lt;splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" /&gt;
          &lt;splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" /&gt;
          &lt;splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" /&gt;
          &lt;splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" /&gt;
          &lt;splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" /&gt;
          &lt;splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" /&gt;
          &lt;splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" /&gt;
          &lt;splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" /&gt;
      &lt;/platform&gt;
      &lt;platform name="ios"&gt;
          &lt;allow-intent href="itms:*" /&gt;
          &lt;allow-intent href="itms-apps:*" /&gt;
          &lt;icon height="57" src="resources/ios/icon/icon.png" width="57" /&gt;
          &lt;icon height="114" src="resources/ios/icon/icon@2x.png" width="114" /&gt;
          &lt;icon height="40" src="resources/ios/icon/icon-40.png" width="40" /&gt;
          &lt;icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" /&gt;
          &lt;icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" /&gt;
          &lt;icon height="50" src="resources/ios/icon/icon-50.png" width="50" /&gt;
          &lt;icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" /&gt;
          &lt;icon height="60" src="resources/ios/icon/icon-60.png" width="60" /&gt;
          &lt;icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" /&gt;
          &lt;icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" /&gt;
          &lt;icon height="72" src="resources/ios/icon/icon-72.png" width="72" /&gt;
          &lt;icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" /&gt;
          &lt;icon height="76" src="resources/ios/icon/icon-76.png" width="76" /&gt;
          &lt;icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" /&gt;
          &lt;icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" /&gt;
          &lt;icon height="29" src="resources/ios/icon/icon-small.png" width="29" /&gt;
          &lt;icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" /&gt;
          &lt;icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" /&gt;
          &lt;icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" /&gt;
          &lt;splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" /&gt;
          &lt;splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" /&gt;
          &lt;splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" /&gt;
          &lt;splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" /&gt;
          &lt;splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" /&gt;
          &lt;splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" /&gt;
          &lt;splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" /&gt;
          &lt;splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" /&gt;
          &lt;splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" /&gt;
          &lt;splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" /&gt;
          &lt;splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" /&gt;
          &lt;splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" /&gt;
          &lt;splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" /&gt;
      &lt;/platform&gt;
      &lt;plugin name="cordova-plugin-whitelist" spec="1.3.3" /&gt;
      &lt;plugin name="cordova-plugin-statusbar" spec="2.4.2" /&gt;
      &lt;plugin name="cordova-plugin-device" spec="2.0.2" /&gt;
      &lt;plugin name="cordova-plugin-splashscreen" spec="5.0.2" /&gt;
      &lt;plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" /&gt;
      &lt;plugin name="cordova-plugin-ionic-webview" spec="^4.0.0" /&gt;
      &lt;plugin name="cordova-plugin-inappbrowser" spec="3.0.0" /&gt;
      &lt;plugin name="cordova-plugin-email-composer" spec="0.9.2"&gt;
          &lt;variable name="ANDROID_SUPPORT_V4_VERSION" value="27.+" /&gt;
      &lt;/plugin&gt;
      &lt;plugin name="cordova-sqlite-storage" spec="3.2.0" /&gt;
      &lt;engine name="android" spec="7.1.4" /&gt;
  &lt;/widget&gt;
  </code></pre>
  
  <p>Any idea how i can solve this problem?</p>