36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
angular.module('bananaraceApp.controllers').controller('ViewerCtrl', ['$scope', '$routeParams', 'TeamService', function($scope, $routeParams, TeamService) {
|
|
|
|
//store all the teams
|
|
$scope.teamsInPoule = [];
|
|
$scope.currentTeamInPouleIndex = -1;
|
|
|
|
$scope.refreshTeamsForPoule = function() {
|
|
var idchampionship = $routeParams.idchampionship;
|
|
var tier = $routeParams.tier;
|
|
var poule = $routeParams.poule;
|
|
ViewerService.getTeamInPoule(idchampionship, tier, poule).
|
|
success(function(data, status, headers, config) {
|
|
console.log('getTeamsInPoule 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('getTeamsInPoule failed...');
|
|
});
|
|
};
|
|
|
|
$scope.goToNextTeamInPoule = function() {
|
|
if($scope.teamsInPoule.length>0) {
|
|
//set up everything for the next team
|
|
$scope.currentTeamInPouleIndex = (($scope.currentTeamInPouleIndex+1)%$scope.teamsInPoule.length);
|
|
} else {
|
|
$scope.currentTeamInPouleIndex = -1;
|
|
}
|
|
};
|
|
|
|
}]);
|