JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.1/angular.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/restangular/1.3.1/restangular.js"></script>
<body ng-app="myApp">
<div ng-controller='MainController'>
<input type='checkbox' ng-model="use$object">Use $Object: {{!!use$object}}</input> {{prompt()}}
<p>{{post}}</p>
<button ng-click="retrieve()">Retrieve Post first</button><button ng-click="modify()">then PUT with modified title</button>
</div>
</body>
</html
JavaScript
angular.module('myApp', ['restangular'])
.config(function(RestangularProvider) {
RestangularProvider.setBaseUrl('http://jsonplaceholder.typicode.com/');
})
.controller('MainController', ['$scope', 'Restangular', function($scope, R) {
$scope.retrieve = function() {
if($scope.use$object) {
$scope.post = R.one('posts', 1).get().$object;
} else {
R.one('posts', 1).get().then(function(p) {
$scope.post = p;
});
}
}
$scope.modify = function() { $scope.post.title = 'Modified title'; $scope.post.put();}
$scope.prompt = function() { return $scope.use$object ? "Will PUT without any change" : "Will PUT with changed title"; }
}]);