From 4e7fff358e234ec7823d801118d084f03a671622 Mon Sep 17 00:00:00 2001 From: Davide Alberani Date: Sat, 21 Mar 2015 13:21:15 +0100 Subject: [PATCH] basic REST services --- angular_app/js/services.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 angular_app/js/services.js diff --git a/angular_app/js/services.js b/angular_app/js/services.js new file mode 100644 index 0000000..d441be9 --- /dev/null +++ b/angular_app/js/services.js @@ -0,0 +1,31 @@ +var eventManServices = angular.module('eventManServices', ['ngResource']); + +eventManServices.factory('Event', ['$resource', + function($resource) { + return $resource('events/:eventID', {eventID: '@eventID'}, { + all: { + method: 'GET', + isArray:true, + transformResponse: function(data, headers) { + return angular.fromJson(data).events; + } + } + }); + }] +); + + +eventManServices.factory('Person', ['$resource', + function($resource) { + return $resource('persons/:personID', {personID: '@personID'}, { + all: { + method: 'GET', + isArray:true, + transformResponse: function(data, headers) { + return angular.fromJson(data).persons; + } + } + }); + }] +); +