I'm sure this will be an easy one for any Angular/Javascript experts. I have a service that makes a call to an API to get some data:
app.service("GetDivision", ["$http", function($http){
this.division = function(divisionNumber){
$http.post("/api/division", {division:divisionNumber}).success(function(data){
return data;
});
}
}]);
Now I call this in one of my controllers like so:
$scope.division = GetDivision.division(1);
However, my service isn't quite right. It doesn't return the value outside of the http request function, so the data doesn't reach the controller calling it. How do I return the data out of both the http request and the function called?