title: Add sqlite query result to angularjs $scope
body: <p>I have this sqlite query in a angularjs app. </p>
  
  <pre><code> $scope.testArr = [];
  
   $scope.testFunk = function(){
  
          var db = window.openDatabase("test", "1.0", "Test DB", 1000000);
  
          db.transaction(function(tx){
  
              tx.executeSql('SELECT * FROM EVENTS',
                            [],
                            //Callback function with transaction and 
                            //results objects
                            function(tx, results){
                                  //Count the results rows
                                  var rowsCount = results.rows.length;  
                                  //Loop the rows
                                  for (var i = 0; i &lt; rowsCount; i++){
                                      //Build a results string, notice the 
                                      //column names are called
  
                                      $scope.testArr.push({                   
  
                                          id: results.rows.item(i).eventId,
                                          nameSel: results.rows.item(i).eventNameSel,
                                          name: results.rows.item(i).eventName,
                                          eventDesc: results.rows.item(i).eventDesc,
                                          eventUrl: results.rows.item(i).eventUrl,
                                          time: results.rows.item(i).eventTime
                                      })
  
                                  }
                                  console.log($scope.testArr);
                             },
                             errorHandler);
           });
        }
  
  //
  </code></pre>
  
  <p>The <code>console.log</code> returns the right objects, but If I do a <code>console.log</code> outside of the <code>db.transaction</code> function it returns empty. The problem is that I want to call the <code>$scope.testFunk()</code> function and return the result from the query to a variable which I then can process further, like:</p>
  
  <pre><code> var result = $scope.testFunk();
   console.log(result); 
   // prints results from query.
  </code></pre>