javascript - RestAngular: put and customPUT are sending old object, not updated one -
when call put or customput , check request body in browser, original object sent, not updated one. checked restangular object {{ object }} , is being updated.
here controller (apiusers restangular service):
$scope.objects = {}; (function waitfornginit(fnct) { $scope.$watch('userid', function(newval) { if (newval !== undefined) { fnct(); } }); })(function retrieveuser() { $scope.objects.user = apiusers.one($scope.userid).get().$object; }); $scope.savesettings = function() { $scope.objects.user.customput($scope.objects.user).then(function(resp) { $scope.errors = []; }, function(err) { console.log(err.data); $scope.errors = err.data.errors; }); }; here jade (html template code):
div.user-settings.form-section(ng-controller="usersettingsformcontroller") {{ objects }} ul.error-box(ng-show="errors != undefined && errors.legnth != 0") li(ng-repeat="error in errors") {{ error.msg }} .form-group label(for="username") username input(type="textfield" ng-model="objects.user.username") .form-group label(for="username") email input(type="textfield" ng-model="objects.user.email") .form-group label(for="username") profile picture input(type="file" ng-model="objects.user.profilepicture") span.submit-button(ng-click="savesettings()") save changes
it old , known restangular bug, see @ https://github.com/mgonto/restangular/issues/713
to make work in meanwhile fixed (it seems working fix it), can use code below:
$scope.submit = function submit() { restangular .copy($scope.ledger) .save() .then(function () { growl.success(gettext('updated successfully.')); }); };
Comments
Post a Comment