Skip to content

Instantly share code, notes, and snippets.

@jb41
Created December 1, 2015 01:21
Show Gist options
  • Save jb41/e84af98bcd3ea93d5f1c to your computer and use it in GitHub Desktop.
Save jb41/e84af98bcd3ea93d5f1c to your computer and use it in GitHub Desktop.
Playing with that using Sheetsu and AngularJS
angular.module('sheetsu').controller 'HomeCtrl', [
'$scope',
'Subjucator',
($scope, Subjucator) ->
$scope.emailSubscribed = false
$scope.useCaseSent = ''
$scope.useCases = {}
currentDate = ->
return (new Date).getTime()
$scope.readUseCases = ->
console.log "readFromUseCases :: Start"
Subjucator.get($scope.urls.useCasesTextsUrl)
.success (response) ->
$scope.useCases = response
console.log $scope.useCases
.error (response) ->
console.log response
console.log "readUseCases :: End"
$scope.saveUseCase = ->
console.log "saveUseCase :: Start"
data =
idea: $scope.formData.useCasesIdeas.idea
timestamp: currentDate()
Subjucator.post($scope.urls.useCasesFormUrl, data)
.success (response) ->
console.log response
$scope.formData.useCasesIdeas.idea = ''
$scope.useCaseSent = 'add-animation'
.error (response) ->
console.log response
console.log "saveUseCase :: End"
return
]
angular.module('sheetsu').service 'Subjucator', [
'$http'
($http) ->
get: (url) -> $http.get(url)
post: (url, data) -> $http.post(url, data)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment