title: "TypeError: Cannot read property 'transaction' of null" while using SQLite in an IONIC app
body: <p>I'm facing this error while embedding SQLite in an ionic app i have read all the relevant articles but none help n this error persist. im sharing my app.js, controller.js and html file.</p>
  
  <hr>
  
  <p>app.js</p>
  
  <pre><code>var starter=angular.module ('starter', ['ionic', 'ngCordova','starter.controllers']);
  
  
  var db=null;
  
  
  starter.run(
  function ($ionicPlatform, $cordovaSQLite)
  {  
  
     $ionicPlatform.ready 
     (
        function()
        {  
           if (window.cordova &amp;&amp; window.cordova.plugins.Keyboard)
           {
              cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
              cordova.plugins.Keyboard.disableScroll(true);
           }
           if (window.StatusBar) 
           {
              StatusBar.styleDefault();
           }
           if(window.sqlitePlugin)
           {
               window.plugins.sqlDB.copy
               (
                   "Tour_MobileApp.db"
                   ,function () 
                   {
                       db = window.sqlitePlugin.openDatabase({name: "Tour_MobileApp.db"});
                   }
                   , function() 
                   {
                       console.error("There was an error copying the database: " + error);
                       db = window.sqlitePlugin.openDatabase({name: "Tour_MobileApp.db"});
                   }
               );  
           }
        }
     );
  });  starter.config(function($stateProvider, $urlRouterProvider) {
  $stateProvider
      .state
      (
          'app', 
          {
              url: '/app',
              abstract: true,
              templateUrl: 'templates/menu.html',
              controller: 'AppCtrl'
          }
      )
      .state
      (
          'app.home', 
          {
              url: '/home',
              views: 
              {
                  'menuContent': 
                  {
                      templateUrl: 'templates/home.html',
                      controller: 'homeCtrl'
                  }
              } 
          }
      )
      .state
      (
          'app.places', 
          {
              url: '/places',
              views: 
              {
                  'menuContent': 
                  {
                      templateUrl: 'templates/places.html',
                      controller: 'placesCtrl'
                  }
              }
          }
      )
      .state
      (
          'app.login',
          {
              url: '/login',
              views: 
              {
                  'menuContent': 
                  {
                      templateUrl: 'templates/login.html',
                  }
              }
          }
      )
      .state
      (
          'app.browse',
          {
              url: '/browse',
              views: 
              {
                  'menuContent': 
                  {
                      templateUrl: 'templates/browse.html',
                  }
              }
          }
      )
      .state
      (
          'app.rfort',
          {
              url: '/rfort',
              views: 
              {
                  'menuContent': 
                  {
                      templateUrl: 'templates/rfort.html',
                  }
              }
          }
      )
      .state
      (
          'app.ltemple',
          {
              url: '/ltemple',
              views: 
              {
                  'menuContent': 
                  {
                      templateUrl: 'templates/ltemple.html',
                  }
              }
          }
      )
      .state
      (
          'app.igate',
          {
              url: '/igate',
              views: 
              {
                  'menuContent': 
                  {
                      templateUrl: 'templates/igate.html',
                  }
              }
          }
      )
      .state
      (
          'app.jmasjid',
          {
              url: '/jmasjid',
              views: 
              {
                  'menuContent': 
                  {
                      templateUrl: 'templates/jmasjid.html',
                  }
              }
          }
      )
      .state
      (
          'app.guide',
          {
              url: '/guide',
              views: 
              {
                  'menuContent': 
                  {
                      templateUrl: 'templates/guide.html',
                  }
              }
          }
      )
      $urlRouterProvider.otherwise('/app/home');
  });
  </code></pre>
  
  <p>controller.js</p>
  
  <pre><code>angular.module('starter.controllers', []) .controller('AppCtrl',function($scope) {}) .controller('homeCtrl',function($scope, $stateParams) {}).controller("placesCtrl", function($scope, $cordovaSQLite) {$scope.categories = [];
  $scope.refresh = function() {
      var query = "SELECT Place_Name, Place_Detail FROM Places_of_interest ORDER BY Place_Name ASC";
      $cordovaSQLite.execute(db, query, []).then(function(res) {
          if(res.rows.length &gt; 0) {
              for(var i = 0; i &lt; res.rows.length; i++) {
                  $scope.categories.push({place_Name: res.rows.item(i).place_Name, Place_Detail: res.rows.item(i).Place_Detail});
                  console.log("SELECTED -&gt; " + res.rows.item(i).Place_Name + " " + res.rows.item(i).Place_Detail);
              }
          } else {
              console.log("No results found");
          }
      }, function (err) {
          console.error(err);
      });
  }});
  </code></pre>
  
  <p>places.html</p>
  
  <pre><code>&lt;ion-view view-title="Places of Interest"&gt;&lt;ion-content ng-controller="placesCtrl"&gt;&lt;ion-list&gt;
     &lt;button class="button button-small button-balanced"ng-click="refresh()" &gt;
        Referesh
      &lt;/button&gt;
     &lt;ion-item ng-repeat="category in categories"&gt;
         {{category.Place_Name}} {{category.Place_Detail}} 
     &lt;/ion-item&gt;
   &lt;/ion-list&gt;
  </code></pre>
  
  <p>
  </p>