i'm having following angularjs function :
this.loadDocument = function() { 
                var documents = [];
                 alert("load documents"); 
                $http({
                     url: 'http://localhost:8085/api/jsonws/dlapp/get-file-entries/repository-id/10182/folder-id/0',
                     method: 'get',             
                     headers: {
                            "Authorization": this.makeAuth(this.username,this.password)
                     }
            }).success(
                    function(response) {
                        alert("sucess");                        
                        documents=response;
                    });
              return documents; 
         };
i called it from following code :
$scope.loadDocument = function() {
        $scope.documents=documentService.loadDocument();
    }
but return value from the function is undefined.because it returns value before success method of ajax call executing.
is there any solution?
Thanks in advance.
 
     
    