I am accessing an API via Angular $http requests to gather information for different football teams.
If I were to be only accessing one team, this would be fine - I would create a Service that made the call, then reference the Service function in my controller. However, I want to do this on numerous teams, without having to create a separate Service module for each one.
Service
app.factory('APIService', ['$http',
function($http) {
return $http.get('http://API/team/1204?Authorization=xxxxx')
.success(function(data) {
return data;
})
.error(function(err) {
return err;
});
}
]);
Inside my Controller...
APIService.success(function(data) {
$scope.apiData = data;
});
As you can see in the Service, the team is specific, "1204", and will only pull in the data from that one team. I want to create a function that allows that four digit code to be interchangeable depending on the team, but I don't know how, or where to put it.
Any help would be massively appreciated. Thanks in advance.