angularjs - restangular nested resources, different url for single resource -
i have following end points:
/quotes (get/post/patch/put) /quotes/{id}/purchase-orders (get/post) /purchase-orders (get) /purchase-orders/{id} (get/patch/put/delete)
when create purchase order via:
restangular.one('quote', {id}).all('purchase-orders').post({params}).then(function(purchaseorder){ console.log(purchaseorder); };
the url on purchaseorder object /quotes/{id}/purchase-orders/{id} want /purchase-orders/{id}. achieving using code below:
restangular.extendmodel('purchase-orders', function(purchaseorder) { if (purchaseorder.parentresource) baserestangular.restangularizeelement(null, purchaseorder, 'purchase-orders'); return angular.extend(purchaseorder, purchaseorder); });
is best/only way?
there configuration option setup parentless routes.
restangular.setparentless(true)
Comments
Post a Comment