The restangular option for updating an object without receiving it from the server

I started using Restangular and it seems to be a very good library. However, I have the following query. To update an object, I use the code below

Restangular.one("accounts", $scope.accountEdit.id).get().then(function(account) {
    account = Restangular.copy($scope.accountEdit);
    account.put();
});

In the above code, I have to fulfill the receive request to the server and then update it. Is there a better way to avoid calling the server since I would like to update an object from my area to the server.

+4
source share
1 answer

you can use customPUTlike this,

Restangular.one("accounts").customPUT($scope.accountEdit, $scope.accountEdit.id).then(function(account) {
     TO-DO
});

customPUT ([elem, path, params, headers]): PUT . . - . , , .

Restangular, , ...

angular.extend($scope.accountEdit, Restangular.one("accounts", $scope.accountEdit.id));
$scope.accountEdit.put();
+4

Source: https://habr.com/ru/post/1533849/


All Articles