restangular icon indicating copy to clipboard operation
restangular copied to clipboard

Document how to add custom methods to nested models

Open ianfp opened this issue 10 years ago • 3 comments

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.

ianfp avatar Feb 12 '15 19:02 ianfp

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

grabbou avatar Feb 19 '15 23:02 grabbou

@ianfp Were you able to resolve this issue?

daviesgeek avatar Jun 17 '16 23:06 daviesgeek

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

ianfp avatar Jun 20 '16 16:06 ianfp