should I return the entire record again as a response from server to a POST when I do $update on an angular resource?

In my factory

return $resource('rest/records/:id', {}, {
        query: {
            method: 'GET',
            isArray: true,
            // RestSQL has an extra struct around the array
            transformResponse: function(data) {
                return angular.fromJson(data).records;
        create: { method: 'POST' },
        update: { method: 'PUT', params: {id: '@id'},

Which is used by a service which is in turn used by a controller.

I get the correct record in the controller.

Then when I edit and want to save the record

I do record.$update();

my rest POST is successful as I get a valid response from server.

But the response from server is just some kind of success message e.g. "{ "number": 2 }".

Now I have an angular template which uses this records properties e.g. {{record.image}}

But as soon as I do record.$update();

records properties disapper and record now simply looks like

record = {"number" : 2}

So should I return the entire record as a response to the POST action or should I update in some other fashion so as to the record doesnt get its properties overwritten by the response from server?

A temporary way of getting around this of course is

$scope.temp = jQuery.extend(true, {}, $scope.record);


I am returning the updated object on POST's, PUT's etc. (see also this: Should a RESTful 'PUT' operation return something) all the time. So,

  • no problem with always returning the updated object in the response
  • don't use tricks and more code to sove a problem that can be solved by applying a very simple solution (in this case, returning the updated object). I love those fixes: Simple solution, problem solved and code removed instead of adding things here and padding things there etc., making code unreadable und unnecessarily complex.

Need Your Help

Jquery image gallery while loop

jquery image gallery

I can't seem to make these images loop and fade in/fade out to make an image gallery. Why is my code not working? I want the images and animation to dissapear after I stop hovering on button1.

Getting a list of filtering attributes for a CRM Plugin (already installed)

plugins dynamics-crm dynamics-crm-4

I have Dynamics CRM 4.0 installed and wrote a plugin, registered it, and setup a "step" that included a few filtering attributes. 2 questions: