Advertisement
Guest User

Untitled

a guest
Sep 27th, 2014
575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. app.factory('ServiceResource', ['$resource', 'authorization', 'baseServiceUrl', function($resource, authorization, baseServiceUrl) {
  2.     var headers = authorization.getAuthorizationHeader();
  3.     var ServiceResource = $resource(baseServiceUrl + '/api/service/:id', null, {
  4.         'public': {  method: 'GET', isArray: true },
  5.         'byId': { method: 'GET', params: { id: '@id' }, isArray: false, headers: headers }
  6.     });
  7.  
  8.     return {
  9.         public: function() {
  10.             return ServiceResource.public();
  11.         },
  12.         byId: function(id) {
  13.             return ServiceResource.byId({id: id});
  14.         }
  15.     }
  16. }]);
  17.  
  18. app.controller('Ctrl', ['$scope', 'ServiceResource', function($scope, ServiceResource) {
  19.     $scope.data = ServiceResource.public();
  20. }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement