I have a service to get User data. The returned data shall be used in a controller.
My problem is, that I can't access the data from db.find inside the getUsers() function.
Service
 app.service('userService', function(){
 this.getUsers = function() {
      var users;
     //neDB find all Users in DB
     db.find({}, function (err, data) {
       queryReturn(data);
     });
     function queryReturn(data) {
       console.log(JSON.stringify(data));
       return data;
     }
   };
});
Controller
app.controller("mainCtrl", function ($scope, userService) {
    $scope.users = '';
    $scope.users = userService.getUsers();
    console.log("Users " + $scope.users);
});
Can anyone give help out with this?
EDIT:
I changed the code in the Service and now I get all the data I want when calling getUsers(). BUT how can I access this data in my controller? It always returns: undefined..
