I'm working with AngularJS a lot right now, but I believe that this is more of a JavaScript question than anything else. Here's snippet from an example controller. Let's assume that it contains an Angular service (defined by me) called 'Restaurants' that I can make queries against.
$scope.myFunction = function() {
    Restaurants.query(function(restaurants) {
        // How to return 'restaurants'?
        return restaurants;
    }
}
The result of Restaurants.query() is handled by the function argument I gave it. My ultimate goal here is to have the 'restaurants' variable be the return value of 'myFunction()'. But when I return from within the nested callback, it doesn't work.
Two questions: - Within the callback, where does the return value ('restaurants') go? - How should I restructure this code so that 'restaurants' can be the return value of 'myFunction()'?
 
    