angular.module('rallly') .controller('EventCtrl', function($scope, $http, $state, Title, Event, ConfirmModal){ var id = $state.params.id; $scope.event = Event.get({id:id}, function(data){ Title.set($scope.event.title); $scope.eventUrl = $state.href('event', { id: $scope.event._id }, { absolute : true }); }, function(e){ $state.go('notfound'); }); $scope.openEvent = function(){ $scope.event.isClosed = false; Event.update({ id : id }, $scope.event, function(){ var modal = new ConfirmModal({ title : 'Event Open', message : 'People can vote and comment on this event.', cancelText : 'OK', }); }); } $scope.closeEvent = function(){ $scope.event.isClosed = true; Event.update({ id : id }, $scope.event, function(){ var modal = new ConfirmModal({ title : 'Event Closed', message : 'People can no longer vote or comment on this event.', cancelText : 'OK', }); }); } $scope.editEvent = function(){ $state.go('editevent', { id : $scope.event._id }); } });