Organize controllers, config
This commit is contained in:
@@ -10,7 +10,12 @@ lunchApp.config ['$routeProvider',
|
||||
.when '/',
|
||||
templateUrl: 'templates/home.html',
|
||||
controller: 'HomeCtrl'
|
||||
.when '/runs',
|
||||
templateUrl: 'templates/runs.html',
|
||||
controller: 'RunsCtrl'
|
||||
.when '/run/:id',
|
||||
templateUrl: 'templates/run.html',
|
||||
controller: 'RunCtrl'
|
||||
]
|
||||
|
||||
lunchApp.config ['$locationProvider',
|
||||
($locationProvider) ->
|
||||
$locationProvider.html5Mode(false).hashPrefix ''
|
||||
]
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
lunchControllers = angular.module 'lunchControllers', []
|
||||
|
||||
lunchControllers.controller 'HomeCtrl', ['$scope', ($scope) ->
|
||||
]
|
||||
|
||||
lunchControllers.controller 'CreateRunCtrl', ['$scope', '$http', 'socket', ($scope, $http, socket) ->
|
||||
$scope.run =
|
||||
invitees: [{email: ''}]
|
||||
|
||||
$scope.addInvitee = () ->
|
||||
$scope.run.invitees.push { email: '' }
|
||||
|
||||
$scope.create = (run) ->
|
||||
data = angular.copy run
|
||||
socket.post '/run', data, (response) ->
|
||||
return
|
||||
]
|
||||
|
||||
lunchControllers.controller 'RunsCtrl', ['$scope', '$http', ($scope, $http) ->
|
||||
$scope.helloMsg = 'hello there boys and girls!'
|
||||
]
|
||||
19
assets/linker/js/controllers/create-run-controller.coffee
Normal file
19
assets/linker/js/controllers/create-run-controller.coffee
Normal file
@@ -0,0 +1,19 @@
|
||||
lunchControllers = angular.module 'lunchControllers'
|
||||
|
||||
lunchControllers.controller 'CreateRunCtrl', ['$scope', '$http', '$location', 'socket', ($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
|
||||
]
|
||||
4
assets/linker/js/controllers/home-controller.coffee
Normal file
4
assets/linker/js/controllers/home-controller.coffee
Normal file
@@ -0,0 +1,4 @@
|
||||
lunchControllers = angular.module 'lunchControllers'
|
||||
|
||||
lunchControllers.controller 'HomeCtrl', ['$scope', ($scope) ->
|
||||
]
|
||||
1
assets/linker/js/controllers/module.coffee
Normal file
1
assets/linker/js/controllers/module.coffee
Normal file
@@ -0,0 +1 @@
|
||||
controllersModule = angular.module 'lunchControllers', []
|
||||
4
assets/linker/js/controllers/run-controller.coffee
Normal file
4
assets/linker/js/controllers/run-controller.coffee
Normal file
@@ -0,0 +1,4 @@
|
||||
lunchControllers = angular.module 'lunchControllers'
|
||||
|
||||
lunchControllers.controller 'RunCtrl', ['$scope', ($scope) ->
|
||||
]
|
||||
@@ -1,6 +1,6 @@
|
||||
lunchServices = angular.module 'lunchServices', []
|
||||
|
||||
lunchServices.factory 'socket', () ->
|
||||
lunchServices.factory 'socket', socketFactory = () ->
|
||||
s = window.io.connect()
|
||||
s.on 'connect', () ->
|
||||
s.on 'message', (message) ->
|
||||
|
||||
Reference in New Issue
Block a user