title: ng-cordova sqlite plugin: TypeError: Cannot read property 'transaction' of null
body: <p>I am trying to get values from database using ionic, ng-cordova, <a href="https://github.com/brodysoft/Cordova-SQLitePlugin" rel="nofollow">sqlite</a> but i keep getting this error:</p>
  
  <pre><code>TypeError: Cannot read property 'transaction' of null: ionic.bundle.js:19387
  </code></pre>
  
  <p>Here is the code:</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;ion-view view-title="Search" ng-controller="AppCtrl2"&gt;
    &lt;ion-content&gt;
      &lt;ion-list&gt;
        &lt;ion-item ng-repeat="item in resultados"&gt;
          Hello, {{item}}!
        &lt;/ion-item&gt;
      &lt;/ion-list&gt;
    &lt;/ion-content&gt;
  &lt;/ion-view&gt;
  </code></pre>
  
  <p>app.js</p>
  
  <pre><code>var db = null;
  
  angular.module('starter', ['ionic', 'starter.controllers','ngCordova'])
  
  .run(function($ionicPlatform,$cordovaSQLite) {
    $ionicPlatform.ready(function() {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
      if (window.cordova &amp;&amp; window.cordova.plugins.Keyboard) {
        cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
      }
      if (window.StatusBar) {
        // org.apache.cordova.statusbar required
        StatusBar.styleDefault();
      }
      db = $cordovaSQLite.openDB({ name: "my.db" });
      $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS people (id integer primary key, firstname text, lastname text)");
      query = "INSERT INTO people (firstname, lastname) VALUES (?,?)";
      $cordovaSQLite.execute(db, query, ["Sumit", "Pal"]).then(function(res) {
          console.log("INSERT ID -&gt; " + res.insertId);
        });
      $cordovaSQLite.execute(db, query, ["Sumti2", "Pal"]);
    });
  })
  </code></pre>
  
  <p>controller</p>
  
  <pre><code>.controller('AppCtrl2', function($scope,$ionicPlatform,$cordovaSQLite) {
  
   $ionicPlatform.ready(function() {
  
      function getCat() {
        var selectQuery = "SELECT * FROM people";
        $cordovaSQLite.execute(db, selectQuery).then(function(result) {
        nombres = []; 
        for(var i=0; i&lt;result.rows.length; i++){
            nombres.push({"nombre":result.rows.item(0).firstname});
          }
        })
      }
      $scope.resultados =  getCat();       
    })
  
  });
  </code></pre>
  
  <p>How can i fix it ? The error could be of because device is not yet ready ?</p>