Skip to content
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

Restangular on sortable, how to save? #1333

Open
marcoriesco opened this issue Feb 25, 2016 · 2 comments
Open

Restangular on sortable, how to save? #1333

marcoriesco opened this issue Feb 25, 2016 · 2 comments

Comments

@marcoriesco
Copy link

I need to change the order of scope, save but me back an error that save() is not a function.

I'm using restangular to create the objects.

The function is triggered Onsort, I tried using http, but also gives me error.

$scope.onChange = function() {
        ApiRestangular.all($scope.section).getList($scope.query).then(function(res){
            $scope.items = res;

            order = ApiRestangular.copy(res);

            console.log(order);

            $scope.sortOptions = {
                animation   : 150,
                onSort: function(){
                    order.put().then(function(){
                        toast.msgToast($scope.section+ ' ...Ordem atualizada!');
                    });
                }
            };
        });
    };

get error:

TypeError: $scope.items.save is not a function localhost:8800/admin/app/controllers.js

@ConcurrentHashMap
Copy link
Collaborator

I'm not quite sure if I understand the problem correctly, but it seems to me like you're trying to call save() on a collection. There is no such function in restangular. save() is only available on objects, but not on a list of objects.

You could implement it on your own by adding a custom method for the collection.

@daviesgeek
Copy link
Collaborator

@marcoriesco Any update? Did this work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants