($scope, $http, SessionService, api)
| 1 | var module = angular.module('scorekeep'); |
| 2 | module.controller('SessionsController', Sessions); |
| 3 | function Sessions($scope, $http, SessionService, api) { |
| 4 | $scope.sessions = SessionService.query(); |
| 5 | |
| 6 | $scope.name = "my session"; |
| 7 | $scope.username = "my name"; |
| 8 | $scope.createSession = function () { |
| 9 | var session = new SessionService(); |
| 10 | session.$save(function() { |
| 11 | session.name = $scope.name; |
| 12 | session.owner = $scope.username; |
| 13 | session.$update({ id: session.id }, function() { |
| 14 | $scope.sessions.push(angular.copy(session)); |
| 15 | }) |
| 16 | } |
| 17 | )}; |
| 18 | $scope.deleteSession = function (index) { |
| 19 | var sessionId = $scope.sessions[index].id; |
| 20 | $http.delete( api + 'session/' + sessionId); |
| 21 | $scope.sessions.splice(index, 1); |
| 22 | } |
| 23 | } |
nothing calls this directly
no outgoing calls
no test coverage detected