Skip to content

Instantly share code, notes, and snippets.

@leehambley
Forked from kylewelsby/miniapp.coffee
Created May 24, 2013 12:33
Show Gist options
  • Save leehambley/5643190 to your computer and use it in GitHub Desktop.
Save leehambley/5643190 to your computer and use it in GitHub Desktop.
app = angular.module('app', ['ngResource'])
app.factory("Result", ["$resource", ($resource) ->
$resource("/scrapes/:scrape_id/results/:id", {scrape_id: "@scrape_id", id: "@id"})
])
app.controller("MainCtrl", ['$scope','Result',($scope,Result)->
$scope.scrape = {id: 1}
$scope.results = []
$scope.getResults = (->
Result.get(scrape_id: $scope.scrape.id,(obj)->
# onSuccess
$scope.results = obj
,(obj)->
# onFailure
alert("Failed with: #{obj.data}")
)
)
$scope.getResult = ((id)->
Result.query({scrape_id: $scope.scrape.id, id: id},(obj)->
# onSuccess
$scope.results = obj
,(obj)->
# onFailure
alert("Failed with: #{obj.data}")
)
)
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment