White Screen of Death while using Sqlite in Provider

Hello,

i’ve a problem using Sqlite in my Provider.

As soon as i try to use the Provider im getting a white screen. No errors in Webdevelopers Console or Shell.

import {Injectable} from 'angular2/core';
import {Http} from 'angular2/http';
import 'rxjs/add/operator/map';
import {Storage, SqlStorage} from 'ionic-angular';
/*
  Generated class for the SyncService provider.

  See https://angular.io/docs/ts/latest/guide/dependency-injection.html
  for more info on providers and Angular 2 DI.
*/
@Injectable()
export class SyncService {
    data: any = null;

    constructor(public http: Http, private storage: Storage) {
        this.storage = new Storage(SqlStorage, {name: 'test'})

    }
}

As soon as i remove the its working again. But at least i need Sqlite in my Provider to sync on Startup

So anything that gets new'd up you don’t need to add to inject into your constructor.

You should be fine to just do

  constructor(public http: Http) {
        this.storage = new Storage(SqlStorage, {name: 'test'})
    }

I would do this:

...
  constructor(public http: Http) {
        this.storage = new Storage(SqlStorage, {name: 'test'})
    }
storage: Storage;
...

That is because .ts would give you red squiggly lines because this is not part of the type/name of the class.

Or you could do

export class SyncService {
    data: any = null;
    storage = new Storage(SqlStorage, {name: 'test'})
    constructor(public http: Http) {}
}
1 Like