mercredi 6 janvier 2016

cordovaSQLite not working, Error: undefined is not an object (evaluating 'n.transaction')

This is the section of code I have pinpointed to be causing the problem:

angular.module('starter.controllers', []).controller('StudentsCtrl', function ($scope, $cordovaSQLite) {

  var query = "SELECT id, student_id, username FROM students";
  var users = [];

  $cordovaSQLite.execute(db, query).then(function (data) {
    $.each(data, function(i, item) {
      users.push(item);
    });
  });

  $scope.users = users;
});

I have included the necessary files for $cordovaSQLite to work. The above code is inside of www/js/controllers.js, as part of the default Ionic tabbed project. $cordovaSQLite works fine inside of www/js/app.js and also works fine in another section of www/js/controllers.js, but the above section of code returns me this error:

0     610246   error    Error: undefined is not an object (evaluating 'n.transaction')

Update: It appears that $cordovaSQLite is equal to undefined here in this function, but I'm not really sure why this is happening.

Aucun commentaire:

Enregistrer un commentaire