lunchControllers = angular.module 'lunchControllers' lunchControllers.controller 'CreateRunCtrl', ['$scope', '$http', '$location', 'socket', CreateRunController = ($scope, $http, $location, socket) -> $scope.run = invitees: [] $scope.addInvitee = () -> $scope.run.invitees.push {} $scope.removeInvitee = (index) -> $scope.run.invitees.splice index, 1 $scope.create = (run) -> data = angular.copy run data.invitees.push name: data.creatorName email: data.creatorEmail socket.post '/run', data, (response) -> $location.path '/run/' + response.id $scope.$apply() $scope.addInvitee() ]