Files
lunchrun.me/assets/linker/js/controllers/create-run-controller.coffee
2014-03-14 13:49:19 -05:00

22 lines
765 B
CoffeeScript

lunchControllers = angular.module 'lunchControllers'
lunchControllers.controller 'CreateRunCtrl', ['$scope', '$http', '$location', 'socket',
CreateRunController = ($scope, $http, $location, socket) ->
$scope.run =
creatorName: 'ben ramey'
creatorEmail: 'ben.ramey@gmail.com'
invitees: [{email: 'bob@bob.com'}]
restaurant: 'subway'
$scope.addInvitee = () ->
$scope.run.invitees.push { email: '' }
$scope.create = (run) ->
data = angular.copy run
socket.post '/run', data, (response) ->
console.log response.id
console.log $location
$location.path '/run/' + response.id
$scope.$apply()
]