Skip to content

Instantly share code, notes, and snippets.

@scttymn
Created May 28, 2013 03:37
Show Gist options
  • Save scttymn/5660377 to your computer and use it in GitHub Desktop.
Save scttymn/5660377 to your computer and use it in GitHub Desktop.
function ThingController($scope, $http) {
var baseUrl = 'http://sinatra-api-example.scottymoon.c9.io';
$http.get(baseUrl + '/things').success(function(data) {
$scope.things = data;
});
$scope.create = function(thing) {
$http.post(baseUrl + '/things', thing).success(function(thing){
$scope.things.unshift(thing);
$scope.thing = null;
});
}
$scope.delete = function(thing) {
$http.delete(baseUrl + '/things/' + thing.id + '/delete').success(function(thing){
$scope.things.splice(thing,1);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment