rallly/public/js/controllers/event.controller.js
Luke Vella 1b20a11bba New Features
- added notifications
- added toggle switches
- added delete feature
- added email verification
2015-01-26 13:11:48 +01:00

47 lines
1.3 KiB
JavaScript

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 });
}
});