Skip to content

Instantly share code, notes, and snippets.

@suissa
Created November 1, 2015 15:46
Show Gist options
  • Save suissa/101e83379643d16c011a to your computer and use it in GitHub Desktop.
Save suissa/101e83379643d16c011a to your computer and use it in GitHub Desktop.
Service do modulo de Beers
(function(){
'use strict';
angular.module('BeerServiceModule', [])
.service('BeerService', BeerService)
;
function BeerService($http) {
var urlBase = '//localhost:3000/beers';
this.items = [];
this.find = function() {
return $http.get(urlBase);
};
this.get = function(id) {
return $http.get(urlBase + '/' + id);
};
this.create = function(data) {
return $http.post(urlBase, data);
};
this.update = function(data) {
return $http.put(urlBase + '/' + data._id, data);
};
this.remove = function(data) {
return $http.delete(urlBase + '/' + data._id, data);
};
};
BeerService.$inject = ['$http'];
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment