title: Using WebSQL in AngularJs Services
body: <p>I am building a hybrid mobile app using cordova and AngularJs. I have setup a WebSQL to store data locally on my app. I am trying to abstract my WebSQL queries to an Angular service. However, whenever I make a call to method in the service from a controller, nothing gets returned. The results variable clearly returns data from the database when I do a console log on it. However it doesn't seem to return the data to my controller. I understand if you are using plain vanilla JS  or other frameworks with angular then the code needs to be wrapped inside $digest / $apply function. I'm not quite sure how to apply it in this instance since the $scope variable is not available inside Angular Services. Below is an example on what I am trying to achieve.</p>
  
  <pre><code>app.service('UserService', function(){
  
      this.getAll = function(){
          db.executeSql("SELECT * FROM users", [], function(tx, results){
              return results.rows;
          });
      }
  
  });
  
  
  app.controller('myCtrl', function($scope, UserService){
  
      $scope.users = UserService.getAll();
  
  });
  </code></pre>
  
  <p>Any help would be much appreciated.</p>