I am using Angular $http requests to access an API and retrieve information about various football teams.
If I were only dealing with one team, it would be simple - I would create a Service that makes the request and then use that function in my controller. However, I want to do this for multiple 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;
});
}
]);
In My Controller...
APIService.success(function(data) {
$scope.apiData = data;
});
The Service code specifies the team as "1204" and retrieves data only from that team. I want to create a way to make the four-digit code interchangeable based on the team, but I'm unsure of how or where to incorporate this functionality.
Any assistance would be greatly welcomed. Thank you in advance.