-
Notifications
You must be signed in to change notification settings - Fork 840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$object.put() method doesn't work as expected #713
Comments
You are just to fast. You have to use |
ok, can I use $scope.company.put(); when loading of this object will be resolved? $scope.company = oneReal.$object; // {id:5,name:'company 5'} // this works as expected. |
I'm having the same issue. I have a service which returns Restangular's $scope.model.name = 'Bar'; This all seems fine, however once I call Edit: I'm now just using |
@AnatolLitnskiy @danharper thanks for the report. Can you please create a plunkr or jsfiddle of this not working so that I can test it out and debug it easier? I'll mark this as a bug. Thanks! |
Hi but jsfiddle not completely suitable to repeat this. For example to get object from server Restangular uses GET method, while jsfiddle needs POST to /echo/json/ adress in this way we can't get needed data to make restangularized element. Here is my attempt to release it in jsfiddle http://jsfiddle.net/v96Py/1/ |
Here's an example: http://jsfiddle.net/v96Py/2/ As you can see, when using the {"id":1,"name":"Dan"} However, when the same code is run for the model using the {"id":1,"name":"Bob"} The server-side code isn't important, it's just returning a dummy object: <?php
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
echo '{"id": 1, "name": "Dan"}'; |
Thanks!! I'll check it out :). |
can this merge with #579. |
Any solution regarding this bug? |
I've just changed my code from and now it works :) |
I have met the same problem. I do not want to use me = Restangular.one('users','me').get().$object
save = ()->
me.avatar = 'new avatar'
console.log me # the new avatar
me.put() # the avatar does not change (from network, I can see the avatar is still the old value) @henyana I tried |
I am experiencing the same issue. Copying the object and then saving does work and stated in above comments. |
I haven't tried the copy method but will do so shortly... ... but the promise method by @danharper over at http://jsfiddle.net/v96Py/2/ does not work in my implementation. The intuitive way I'd expect this to work would be like so: //init data
var itemRqst = Restangular.one('foo').get()
itemRqst.then( function() { $scope.item = itemRqst.$object });
//save data
var saveRqst = $scope.item.put() //or .save() //should be sending modified data, not original.
saveRqst.then( function() { $scope.item = saveRqst.$object }); |
btw, the 'copy' fix doesn't seem to work for getList. I tried digging into the addRequestInterceptor but the problem arises before making it to that stage as the element parameter has the original data. |
it seems that, after |
If I Restangular.restangularizeElement the element before I |
Any progress on this bug?
|
problem is on this line filledValue is loosing reference to data |
I'm also running into this problem.
The old version is sent off and @chilly90's fix worked for me.
The new correct version is sent of and |
+1 |
Yup, same issue here. |
Copy definitely works, is there any traction on an actual fix for this issue? This had me stuck for quite a while before I found this issue. |
Given the severity of the issue and lack of action for quite a long time, I wonder if the project is still being actively supported / developed. Looking at the commit history of master branch I don't see any commit by the original author @mgonto in months. Though I do some see some recent actively on couple of branches by @grabbou. Would be nice if the community was updated on the status of the project so that just in case the author / contributors of the project are not longer able to maintain it people can move on. |
@ADmad - I am working with @mgonto to fix all the bugs as soon as possible. He's not available at the moment to maintain the project actively as he's giving few talks (e.g. ng-conf). We are in touch all the time having weekly Hangouts so we are pretty on the way to release 1.5 soon. New release should come out in ~2 weeks with most bugs fixed. We have actually reduced number of opened issues from 180 to around 110 which is a great progress. There are still few PRs waiting to be merged which takes some time as they've been done ages ago so they need some extra loving in order to make them master ready. |
Thanks @gonzofish I did work it out in the end. But your example is very helpful and would be nice to something like it in the documentation. |
No problem @garhbod the only problem is that the isServer variable is specific to my data...that is, I know that only the data coming from the server could have an ID field on it...while this is probably common for a lot of projects, it isn't necessarily universal, which makes the docs a little less straightforward to write. |
@mgonto, do you have any update on if this will be soon fixed? Was it included in the recent versions? PUT requests are somewhat important... :) |
+1 |
+1, any news on this? |
+1, any news? |
+1, but the using |
+1 |
+1 |
i'm unsubscribing this thread. tired of here is my way to wrap RESTful api for angular:
you can build a
and i think this is way much easier.. |
Tired of this as well. We switched to restmod instead. Dňa 20 Jul 2015, o 06:45, Ya Zhuang [email protected] napísal:
|
hmm.. looks good to me, worth trying |
I've created a solution. I don't know why it hasn't being pulled yet |
@picitujeromanov, thak you for the suggestion. In few minutes I migrated from restangular, that was with this bug, to restmod and now my app is working fine. |
You're welcome Dňa 21 Jul 2015, o 12:50, Arthur Silva [email protected] napísal:
|
i'm going back to $http & $q... |
I had the same problem. Using:
solved the issue. Thanks to the community! |
Restangular.copy(resourceToUpdate).save() makes PUT request all the time however save should distinguish between POST and PUT |
looks like project is kind of abandoned! |
Restangular v1.5.1 Same problem for me, using |
Hey all, I discovered that (at least in my case) this is actually not a bug with Restangular. My problem was that I was using https://github.com/mgonto/restangular#copying-elements
I hope this helps! |
Closing as a duplicate of #579. Tracking changes there… |
Had to settle for the The interesting thing is that if I |
@deleugpn The comment was pointing out the fact that you need to copy an element using |
@daviesgeek I don't understand Angular enough to answer that. All I know is that I pass the object from one Angular Component to another through a scope variable |
var oneReal = Restangular.one('company',5).get();
// after it will be loaded in controller
$scope.company = oneReal.$object; // {id:5,name:'company 5'}
$scope.company.name = "company 5 edited";
$scope.company.put();
// sends old name 'company 5' not 'company 5 edited'
// Do I have to use method "then(c)" to get loaded object, why I can't use $object that I put in template?
The text was updated successfully, but these errors were encountered: