2

I have the following situation:

I use ngResource to save some data to the mysql database and after the successfull save() I want to log the json response the server sends to me:

Document.save({}, postData, function(response){
    console.log(response);
});

This does not result in a simple response, but in something like an object with its own methods. I want some smple output like the response.data after an $http.$get:

{
    "docClass":"testets",
    "colCount":1,
    "columns":null,
    "groupid":7,
    "id":19,
    "lang":"de",
    "title":"test",
    "version":1409849088,
    "workflow":"12234"
}

Greets

1 Answers1

0

Check out this answer Promise on AngularJS resource save action

So I think in your case you need to do

var document = new Document(postData);
document.$save()
    .then(function(res){});

But also from the link I provided

This may very well means that your call to $save would return empty reference. Also then is not available on Resource api before Angular 1.2 as resources are not promise based.

Community
  • 1
  • 1
gaskar
  • 113
  • 8