title: Usage of interceptor within $resource
body: <p>How do I use an <code>interceptor</code> within an Angular <code>$resource</code>?</p>
  
  <p>My JSON structure:</p>
  
  <pre><code>var dgs = [{id    :1,
              driver:'Sam',
              type:  'bus',
              segments:[{id:1,origin:'the bakery',arrival:'the store'},
                        {id:2,origin:'the store' ,arrival:'somewhere'}]
              },
              { ... },
              { ... }
            ];
  </code></pre>
  
  <p>My controller is the following:</p>
  
  <pre><code>function dgCtrl($scope,$http,DriveGroup,Segment) {
    $scope.dgs = DriveGroup.query(function()
      // Code below may belong in a response interceptor?
      for (var i=0;i&lt;$scope.dgs.length;i++) {
        var segments = $scope.dgs[i].segments;
        for (var j=0;j&lt;segments.length;j++) {
          segments[j] = new Segment(segments[j]);
        }
      }
    });
  </code></pre>
  
  <p>My services, and what I tried using the <code>interceptor</code> object:</p>
  
  <pre><code>angular.module('dgService',['ngResource']).
    factory("DriveGroup",function($resource) {
      return $resource(
        '/path/dgs',
        {},
        {update:{method:'PUT'})
        {fetch :{method:'GET',
                 // This is what I tried.
                 interceptor:{
                   response:function(data) {
                     console.log('response',data);
                   },
                   responseError:function(data) {
                     console.log('error',data);
                   }
                 },
                 isArray:true
                }
      );
  });
  </code></pre>
  
  <p>I read <a href="http://docs.angularjs.org/api/ngResource.%24resource">$resource</a>, and it seems like this should work, but it doesn't, so I'm mis-understanding. Any suggestions?</p>