2

I'm looking at switching from resource to restangular in my AngularJS app. I like the new model, but I have one problem. I can't figure out how to make this API call:

http://localhost:8000/api/entity/groups/1,2,3,4/events

I have code like this:

var GroupService = ['Restangular', function (Restangular) {
    var restAngular = Restangular.withConfig(function (Configurer) {
        Configurer.setBaseUrl('/api/entity');
    });

    return {
        getEvents: function (groupIds) {
            return restAngular.all('groups', groupsIds).getList('events');
        }
    }
}];

Is there a way to ask for a set of groups (more than one and not all of them) and then get all events for any of those groups?

1 Answer 1

6

Use several method of Restangular

Restangular.several('accounts', 1234, 123, 12345).customGETLIST('events');

P.S.: I think this might be a bug of Restangular that .getList('events') is not working.

Sign up to request clarification or add additional context in comments.

7 Comments

Wow, I totally missed that in the API. Thank you!
Can you pass an array as the second argument to several? My backend returns the ids of the objects associations.
If it just appends the comma separated list, I guess I can just join the array and add it to the end of the base route.
@CleoR I don't think you can. But you can creatively use apply method.
@Daiwei wouldn't it be awesome if you could just send an array of ids?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.