mardi 22 septembre 2015

Ionic application won't run on mobile with SQLite plugin [ngCordova]

I'm using ngCordova because it is a massive collection of plugins, but the plugin in particular that I am having the problem with is the SQLite plugin. In my ApplicationController which is initialized when the application starts I have a basic ready check followed by a database initialization which is provided in the SQLite documentation which I had linked above.

Here is the code for the controller.

function applicationController($scope, $rootScope, $cordovaSQLite, $ionicPlatform) {
    // Represents a connection to the local SQLite database.
    $rootScope.database = null;

    // Constructs a connection to the local SQLite database.
    $ionicPlatform.ready(function() {
        $rootScope.database = $cordovaSQLite.openDB({ name: "test.db" });
        alert("Database: " + JSON.stringify($rootScope.database));
    });

    console.log("APPLICATION INITIALIZED"); 
}

The error that occurs is that of a broken module, the entire screen stays white and there is no progress or alert from the .ready call. When commenting out the $cordovaSQLite.openDB command, the page loads like normal and outputs Database: null as expected in the alert.

Anybody know what the issue may be?

Aucun commentaire:

Enregistrer un commentaire