Files
lunchrun.me/assets/linker/js/controllers/create-run-controller.coffee
2014-03-25 22:10:41 -05:00

22 lines
656 B
CoffeeScript

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
socket.post '/run', data, (response) ->
$location.path '/run/' + response.id
$scope.$apply()
$scope.addInvitee()
]