title: Angular $resource and use of Interceptor to check response/error/callback
body: <p>Last few days I am working to invoke REST services and track the response, error, callback etc. I have gone through most of the posting however due to my limited understanding on Angular seems like I am not able to understand it. Following is my problem and understanding I got so far.</p>
  
  <p>I am using Project.$update() service which returns only "project_id". This server doesn't return complete data again. Following is line of few line of code to share here.</p>
  
  <pre><code>//create Project factory
  app.factory('Project', function ($resource) {
      return $resource('/api/projects/:projectid',
              {projectid:'@id'},
              {update: {method:'PUT', isArray:false}}    
      );
  
  });
  </code></pre>
  
  <p>Following is code in directive I am using to update/create project.</p>
  
  <pre><code>//save project
              scope.saveProject = function (project) {
                  //update modified by field
                  project.modifiedby = scope.user._id;
                  //change to view mode
                  scope.projectView = 1;
                  //call server to save the data                
                  if (project._id == undefined || project._id == "") {
  
                      //Call server to create new and update projectID
                      project._id = project.$save()._id;
                  }
                  else {
                      //Call server to update the project data
                      project.$update({ projectid: project._id });
                  }
  
  
              };
  </code></pre>
  
  <p>Following is service response for both save() and update().</p>
  
  <pre><code>{"_id":"52223481e4b0c4d1a050c25e"}
  </code></pre>
  
  <p>Problem here is; "project" object value is replaced by new response returned by server having only project_id and other fields are replaced. </p>
  
  <p>I was going through detailed documentation on $resource however I am not able to grasp it. It will be great to get some guidance here to write code to detect error, response, callback.</p>