mgonto / restangular

AngularJS service to handle Rest API Restful Resources properly and easily
MIT License
7.87k stars 840 forks source link

Document how to add custom methods to nested models #1043

Open ianfp opened 9 years ago

ianfp commented 9 years ago

Can you document how to add custom methods to a nested resource? My code looks like this:

    app.factory('Storefront', ['Restangular',
    function(Restangular) {
        return Restangular.service('storefront');
    }]);

    app.controller('StorefrontProductList', [
        '$scope', '$filter', 'Storefront',
    function($scope, $filter, Storefront) {
        Storefront.one(storeId).get().then(function(store) {
            $scope.store = store;

            store.getList('products').then(function(products) {
                $scope.products = products;
            });
        });
    }]);

I want to add custom methods to products, which are nested under storefronts like so: /storefront/{id}/products.

grabbou commented 9 years ago

Can you check this PR? https://github.com/FabienDehopre/restangular/commit/204dab5fc44617bb92fa1e1829ae4bceb0fe0b2d I think that should work for you.

daviesgeek commented 8 years ago

@ianfp Were you able to resolve this issue?

ianfp commented 8 years ago

@daviesgeek I haven't because I've been migrating to Angular2 and have phased out Restangular. Sorry!