Created
May 28, 2013 03:37
-
-
Save scttymn/5660377 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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