I'm starting to read about services in Angular and confused as to how to use them with $http.
I currently use $http to fetch data from my REST API like the code below;
$scope.getRestaurant = function () {
var baseUrl = 'http://api.example.com/web/restaurant/details/' + $scope.id;
$http({
method: 'get',
url: baseUrl,
headers: {'Content-Type': 'application/json'}
}).
success (function(data, status, headers, config){
if(data && !angular.isUndefined(data) ){
$scope.restaurant = data;
} else {
$scope.restaurant = [];
}
}).
error(function(data, status, headers, config) {
//$scope.messageFailure(data.message);
});
}
$scope.id is a value on my controller how can I turn this function into service and then access the data returned in my controller?