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

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -