title: How do I use the ngCordova sqlite service and the Cordova-SQLitePlugin with Ionic Framework?
body: <p>I have been trying to incorperate sqlite into a simple Ionic app and this is the process I have been following:</p>
  
  <pre><code> ionic start myApp sidemenu
  </code></pre>
  
  <p>Then I install the sqlite plugin:</p>
  
  <pre><code>ionic plugin add https://github.com/brodysoft/Cordova-SQLitePlugin
  </code></pre>
  
  <p>and ngCordova</p>
  
  <pre><code>bower install ngCordova
  </code></pre>
  
  <p>this gave me the following options:
  Unable to find a suitable version for angular, please choose one:
      1) angular#1.2.0 which resolved to 1.2.0 and is required by ngCordova#0.1.4-alpha 
      2) angular#>= 1.0.8 which resolved to 1.2.0 and is required by angular-ui-router#0.2.10 
      3) angular#1.2.25 which resolved to 1.2.25 and is required by angular-animate#1.2.25, angular-sanitize#1.2.25 
      4) angular#~1.2.17 which resolved to 1.2.25 and is required by ionic#1.0.0-beta.13Prefix the choice with ! to persist it to bower.json</p>
  
  <p>I picked option 3)
   and I included the scripts in the file as follows:</p>
  
  <pre><code>&lt;script src="lib/ionic/js/ionic.bundle.js"&gt;&lt;/script&gt;
  &lt;script src="lib/ngCordova/dist/ng-cordova.js"&gt;&lt;/script&gt;
  &lt;script src="cordova.js"&gt;&lt;/script&gt;
  &lt;script src="js/app.js"&gt;&lt;/script&gt;
  &lt;script src="js/controllers.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I then added a controller to the search view:</p>
  
  <pre><code>.controller('SearchCtrl', function ($scope, $cordovaSQLite){
    console.log('Test');
     var db = $cordovaSQLite.openDB({ name: "my.db" });
  
          // for opening a background db:
          var db = $cordovaSQLite.openDB({ name: "my.db", bgType: 1 });
  
          $scope.execute = function() {
            console.log('Test');
            var query = "INSERT INTO test_table (data, data_num) VALUES (?,?)";
            $cordovaSQLite.execute(db, query, ["test", 100]).then(function(res) {
              console.log("insertId: " + res.insertId);
            }, function (err) {
              console.error(err);
            });
       };
  })
  </code></pre>
  
  <p>This caused the error:</p>
  
  <pre><code>&gt; TypeError: Cannot read property 'openDatabase' of undefined
  &gt;     at Object.openDB  (http://localhost:8100/lib/ngCordova/dist/ng-cordova.js:2467:36) 
  </code></pre>
  
  <p>Next I tried manually including the SQLitePlugin.js by:
  copying from <strong><em>plugins/com.brodysoft.sqlitePlugin/www</em></strong> to main <strong><em>www/</em></strong> and adding it to the index.html page</p>
  
  <p>I tried including before everything:</p>
  
  <pre><code> &lt;script src="SQLitePlugin.js"&gt;&lt;/script&gt;
  &lt;script src="lib/ionic/js/ionic.bundle.js"&gt;&lt;/script&gt;
  &lt;script src="lib/ngCordova/dist/ng-cordova.js"&gt;&lt;/script&gt;
  &lt;script src="cordova.js"&gt;&lt;/script&gt;
  &lt;script src="js/app.js"&gt;&lt;/script&gt;
  &lt;script src="js/controllers.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I get Error <strong>ReferenceError: cordova is not defined</strong>
  so I then tried including it after the cordova.js script but still get the same error</p>
  
  <p>would really appreciate the help
  in case it is relevant, these are the current versions of Cordova and ionic I am using:</p>
  
  <pre><code>ionic --version  1.2.5
  cordova --version 3.5.0-0.2.7
  </code></pre>
  
  <p>and this is the generated bower.json</p>
  
  <pre><code>{
    "name": "myApp",
    "private": "true",
    "devDependencies": {
      "ionic": "driftyco/ionic-bower#1.0.0-beta.13"
    }
  }
  </code></pre>
  
  <p>and my package.json:</p>
  
  <pre><code>{
    "name": "myapp",
    "version": "1.0.0",
    "description": "myApp: An Ionic project",
    "dependencies": {
      "gulp": "^3.5.6",
      "gulp-sass": "^0.7.1",
      "gulp-concat": "^2.2.0",
      "gulp-minify-css": "^0.3.0",
      "gulp-rename": "^1.2.0"
    },
    "devDependencies": {
      "bower": "^1.3.3",
      "gulp-util": "^2.2.14",
      "shelljs": "^0.3.0"
    }
  }
  </code></pre>