I am trying to retrieve data from a SQL database and wrote the following function:
$scope.sqlRequest = function (Req) {
console.log("Main.js requesting from DB :", Req)
return server_operations.sqlRequest([Req])
.success(function (Results) {
console.log("Results returned to .success = ", Results);
return Results.data
});
}
When I run the function the results are displayed correctly in the console. But when I try to use the data in any further context like:
Res = $scope.sqlRequest("<Some SQL String here>")
the variable Res will always be undefined. What do I have to change to get the data into a global variable ?