Cannot resolve all parameters

Hi all,

I have the following peace of code in my app.js file that will trow me an exception but I’ve no idea why and how to fix it.

import ‘es6-shim’;
import {App, Platform, Storage, SqlStorage} from ‘ionic-angular’;
import {StatusBar} from ‘ionic-native’;
import {TabsPage} from ‘./pages/tabs/tabs’;

@App({
providers: [Storage],
template: ‘<ion-nav [root]=“rootPage”>’,
config: {
tabbarPlacement: ‘top’
}
// Config - Ionic API Documentation - Ionic Framework
})
export class MyApp {
static get parameters() {
return [[Platform], [Storage]];
}

constructor(platform: Platform, storage: Storage) {
this.rootPage = TabsPage;

platform.ready().then(() => {
  // Okay, so the platform is ready and our plugins are available.
  // Here you can do any higher level native things you might need.
  StatusBar.styleDefault();
  
  this.storage = new Storage(SqlStorage, null);
  this.storage.query("CREATE TABLE IF NOT EXIST people (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)").then((data) => {
      console.log("TABLE CREATED -> " + JSON.stringify(data.res));
  }, (error) => {
      console.log("ERROR -> " + JSON.stringify(error.err));
  })      
  
});

}
}

Hope you guys might see what is wrong with this code.

I would try and match things up with the way Ionic’s Conference App is coded - I think you have some differences.

Forgot to put the exact error message that is thrown:

Cannot resolve all parameters for ‘Storage’(?, ?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that ‘Storage’ is decorated with Injectable.

Take a look here - its different to yours.

1 Like

Thanks. This example helped me fix the problem. Did not need to add Storage provider and it was also not needed to add it as a parameter to the constructor.