Reputation: 96
I am having trouble with $resource
on one of my angular projects. All of a sudden it has started to mess up the objects that are sent to the server on $save
.
Calls to $save
on $resource
objects does not strip away $resolved
and $promise
from the JSON data that is posted to my server.
The resource behaves like normal except this.
So If i were to call $save
on an article -> this is what's actually being sent to the server:
{
"id":999,
"title":"test 2",
"text":"",
"file":null,
"url":null,
"pdato":"0000-00-00 00:00:00",
"author_id":0,
"status":0,
"lang":"",
"parent":0,
"$promise":{},
"$resolved":true
}
The two last properties are the problem. I've never had this problem on other projects. Is it true that angular filters the resource object through angular.toJson
before it sends it to the server, and this operation is supposed to remove the $promise
/$resolved
properties?
When I do a console.log(angular.toJson(article));
(article is a fetched resource object) - it also logs the $promise
and $resolved
properties.
What can cause this behaviour?
Upvotes: 0
Views: 288
Reputation: 96
Turns out I had a different version of angular-resource than angular. Changed my dependencies versions in bower.json to this:
"angular": "~1.3.0",
"angular-resource": "~1.3.0" // this was ~1.2.0
Upvotes: 1