angularjs $resource callback

I have this model called Project and whose members are rows in a table, more specifically, a table decorated by the jQuery DataTables plugin

Here's my project model in coffeescript

#= require vendor/angular.js

Project = angular.module('Project', ['ngResource'])
.value( 'csrf', $('meta[name="csrf-token"]').attr('content') )

.factory('Project', ['$resource','csrf', ($resource, csrf) ->
  $resource '/projects/:project_id/:action', {authenticity_token: csrf, project_id:'@id'},
    query:
      method: 'GET'
      isArray: yes
    new:
      method: 'GET'
      params:
        project_id: 'new'
    edit:
      method: 'GET'
    update:
      method: 'PUT'

])

Ene drawback of the DataTable plugin used alongside angular is that whenever I so a project.$update(), that project disappears from the view

So I have to sort of reload the DataTable by re-initializing it, I can live with that for now but I was wondering then, if there is a way that I can set a universal callback for $resource, where I can put this DataTables re-initialization call?

thanks!

I'm assuming that in the controller from whence you call the factory you have some sort of wrapper method.

lets call it scope.crudData

 SomeCtrl = (scope, http, projectService)
      scope.crudData(p_id, act, method) ->
          meth = YOUR LOGIC FOR PARSING AN ACTUAL FUNCTION FROM THE METHOD NAME GOES HERE
          projectService.meth
              project_id: p_id
              act: action
          , (response) ->
               THIS IS WHERE YOUR CALLBACK LIVES. KNOCK YOURSELF OUT. RELOAD THE DATA DO ANYTHING YOU WANT

If that's not good enough, you could I suppose register a listener in config for all ajax requests, verify the data, etc.

Let me know if that's what you are looking for and I'll put together some pseudocode for you.