Created
November 1, 2015 15:46
-
-
Save suissa/101e83379643d16c011a to your computer and use it in GitHub Desktop.
Service do modulo de Beers
This file contains hidden or 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(){ | |
'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