Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

Precompiled SQLight DB - Cannot read property 'transaction' of null

$
0
0

@nadir_bertolasi wrote:

I'm following this guide:

I get this problem:

error TypeError: Cannot read property 'transaction' of null
at Object.execute (http://192.168.0.10:8100/js/ng-cordova.min.js:9:19174)

I think it is due to the fact that home controller is launched before that copy is finished.

This is my code:

app.run(function($ionicPlatform, $cordovaSQLite) {

    $ionicPlatform.ready(function() {
        if(window.cordova && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
        }
        if(window.StatusBar) {
            StatusBar.styleDefault();
        }

        window.plugins.sqlDB.copy("comeInComoDB.db", function() {
            console.log('db copy completed');
            db = $cordovaSQLite.openDB("comeInComoDB.db");
        }, function(error) {
            console.error("There was an error copying the database: " + JSON.stringify(error));
            db = $cordovaSQLite.openDB("comeInComoDB.db");
        });



    });
});

My HomeCtrl

  app.controller('HomeCtrl', function($scope, $rootScope, $cordovaLaunchNavigator, $cordovaSQLite) {

  var query = "SELECT name FROM monument";

  $cordovaSQLite.execute(db, query, []).then(function(res) {
      if(res.rows.length > 0) {
          for(var i = 0; i < res.rows.length; i++) {
              console.log("SELECTED -> " + res.rows.item(i).name);
          }
      } else {
          console.log("No results found");
      }
  }, function (err) {
      console.error('Error executing Query!');
      console.error(JSON.stringify(err));
  });

I also have seen that commenting query code on HomeCtrl I don't get any error, but also I see that console.log('db copy completed');

I think that my copy doesn't complete and remains appended.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>