Working run save

This commit is contained in:
Ben Ramey
2014-03-12 21:49:16 -05:00
parent e18e186be0
commit 0fbee6ecc9
6 changed files with 45 additions and 33 deletions

View File

@@ -1,6 +1,7 @@
lunchApp = angular.module 'lunchApp', [
'ngRoute',
'lunchControllers'
'lunchControllers',
'lunchServices'
]
lunchApp.config ['$routeProvider',
@@ -9,7 +10,7 @@ lunchApp.config ['$routeProvider',
.when '/',
templateUrl: 'templates/home.html',
controller: 'HomeCtrl'
.when '/runs',
.when '/runs',
templateUrl: 'templates/runs.html',
controller: 'RunsCtrl'
]

View File

@@ -4,10 +4,16 @@ lunchControllers.controller 'HomeCtrl', ['$scope', ($scope) ->
]
lunchControllers.controller 'CreateRunCtrl', ['$scope', '$http', 'socket', ($scope, $http, socket) ->
$scope.stuffs = [{name: 'my name'}]
$scope.run =
invitees: [{email: ''}]
$scope.addInvitee = () ->
$scope.run.invitees.push { email: '' }
$scope.create = (run) ->
socket.post '/run', run, (response) ->
data = angular.copy run
socket.post '/run', data, (response) ->
return
]
lunchControllers.controller 'RunsCtrl', ['$scope', '$http', ($scope, $http) ->

View File

@@ -1,8 +1,10 @@
socketModule = angular.module 'socketModule', []
socketModule.factory 'socket', ()->
s = window.io.connect()
s.on 'connect', ()->
s.on 'message', (message)->
console.log 'New comet message received :: ', message
lunchServices = angular.module 'lunchServices', []
return socket
lunchServices.factory 'socket', () ->
s = window.io.connect()
s.on 'connect', () ->
s.on 'message', (message) ->
console.log 'New comet message received :: '
console.log message
return s