Skip to content

Instantly share code, notes, and snippets.

@demetriusnunes
Created March 13, 2014 13:36
Show Gist options
  • Save demetriusnunes/9528614 to your computer and use it in GitHub Desktop.
Save demetriusnunes/9528614 to your computer and use it in GitHub Desktop.
angular.module('ProductsService', []).factory('Products', ['$http', function ($http) {
return {
get: function () {
return $http.get('/api/products');
},
create: function (data) {
return $http.get('/api/products', data);
},
delete: function (id) {
return $http.delete('/api/products/' + id);
}
}
}]);
angular.module('myApp').controller('ProductsCtrl', function ($scope, ProductsService) {
ProductsService.get().success(function (data) {
$scope.products = data;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment