question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PUT not putting changes when model is get through $object

See original GitHub issue

restanglar v1.3.1

$scope.data = Restangular.one("collection", "1245").get().$object;
// I got back

{ 
  title: "some title"
}

$scope.data.title = "title 123";
$scope.data.put();

It will not put the changes.

But if get through promise it will work.

Restangular.one("collection", "1245").get().then(function(result) {
  $scope.data = result;
});
$scope.data.title = "title 123";
$scope.data.put(); // will work

Issue Analytics

  • State:open
  • Created 10 years ago
  • Reactions:1
  • Comments:24 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
saniakycommented, Dec 8, 2016

+1

0reactions
ThomasCedrinicommented, Mar 7, 2017

@peter-bertuglia Great !! Here is an upgrade handling collections as well as element.

Restangular.addResponseInterceptor(function (data, operation, what, url, response, deferred) {
    var el = _.extend(deferred.promise.$object, data);

    if(angular.isArray(el))
	return Restangular.restangularizeCollection(data[Restangular.configuration.restangularFields.parentResource], el, what);

    return Restangular.restangularizeElement(data[Restangular.configuration.restangularFields.parentResource], el, what);
});

EDIT

There were too much codes… this is well enough :

Restangular.addResponseInterceptor(function (data, operation, what, url, response, deferred) {
    return _.extend(deferred.promise.$object, data);
});

With the previous version, if you did a Restangular.extendModel, you received twice each resource instead of once. And when working with events, those were triggered twice…

Bye !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django model method not making changes to object
1 Answer 1 · you set a variable with a single equal sign ( = ), not a double equal sign ( ==...
Read more >
Why we Avoid Putting Value Objects in Events
What's the harm in putting Value Objects in your Events? ... As your domain model evolves, you may add new invariants to be...
Read more >
PutObject - Amazon Simple Storage Service
To successfully change the objects acl of your PutObject request, you must have the s3:PutObjectAcl in your IAM permissions. To successfully set the...
Read more >
Using Objects - The Java™ Tutorials
Once you've created an object, you probably want to use it for something. You may need to use the value of one of...
Read more >
Link or embed a PowerPoint slide in a Word document
If you insert the slide into the document as a PowerPoint object, Word runs PowerPoint when ... The presentation object can be embedded...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found