There may be something very obvious I'm missing here, but I cannot get my Angularjs service to return a list of users from my Firebase datastore.
This is not a question of how to generically return a response from an ajax call, but more about the appropriate use of how to handle Firebase's Promises within an Angularjs service
.service('userService', function() {
    var data; //initialize data variable
    this.getUsers = function() {
        var ref = firebase.database().ref('/users/');
        ref.once('value').then(function(snapshot) {
            users = snapshot.val(); //returns a list of user objects
        }).then(function(){
            data = users //this populates data with all the user objects
        }, function(error){
            alert('error:  ' + error);
        });
    }
    return data; //data is undefined here
}]);
I suspect it has to do with then() function but I've been banging my head on this for way too long - any ideas?
 
     
    