angular.module('bananaraceApp.controllers').controller('PouleViewerCtrl', ['$scope', '$routeParams', 'TeamService', function($scope, $routeParams, TeamService) { //store all the teams $scope.teamsInPoule = []; $scope.refreshTeamsForPoule = function() { var idchampionship = $routeParams.idchampionship; var tier = $routeParams.tier; var poule = $routeParams.poule; ViewerService.getTeamsForPoule(idchampionship, tier, poule). success(function(data, status, headers, config) { console.log('getTeamsForPoule successful...'); console.log(data); if(data['ok']==true) { $scope.teamsInPoule = data.teams; } else { console.log('call returned but wasnt ok: '+data.error); } }). error(function(data, status, headers, config) { console.log('getTeamsForPoule failed...'); }); }; //check if we need to load the teams for poule: only if }]);