32 lines
853 B
JavaScript
32 lines
853 B
JavaScript
var CreateRunController, lunchControllers;
|
|
|
|
lunchControllers = angular.module('lunchControllers');
|
|
|
|
lunchControllers.controller('CreateRunCtrl', [
|
|
'$scope', '$http', '$location', 'socket', CreateRunController = function($scope, $http, $location, socket) {
|
|
$scope.run = {
|
|
name: 'run name',
|
|
creatorName: 'ben ramey',
|
|
creatorEmail: 'ben.ramey@gmail.com',
|
|
invitees: [
|
|
{
|
|
name: 'bob',
|
|
email: 'bob@bob.com'
|
|
}
|
|
],
|
|
restaurant: 'subway'
|
|
};
|
|
$scope.addInvitee = function() {
|
|
return $scope.run.invitees.push({});
|
|
};
|
|
return $scope.create = function(run) {
|
|
var data;
|
|
data = angular.copy(run);
|
|
return socket.post('/run', data, function(response) {
|
|
$location.path('/run/' + response.id);
|
|
return $scope.$apply();
|
|
});
|
|
};
|
|
}
|
|
]);
|