restangular icon indicating copy to clipboard operation
restangular copied to clipboard

Adding custom methods does not paly nice with the "one" method

Open wastedUltimate opened this issue 11 years ago • 0 comments

Using the 'one' requestless method seems do have undesired behavior when an ElementTransformer is defined for a non-collection.

Restangular.addElementTransformer('accounts', true, fn1);
Restangular.addElementTransformer('accounts', false, fn2);
var baseAccounts = Restangular.all('accounts'); //Properly restangularized with 'accounts' collection transformer
var account1 = baseAccounts.one('id1'); //Does not get restangularized with 'accounts' element transformer

The route case seems to be that calling 'one' with a single parameter assumes that the single parameter is the route and ultimately restangularizes the following object which would not match the 'accounts' transformer:

account1 = {
    route: 'id1',
    parentResource: {route: 'accounts', parentResource: null}
}

Is there a way to properly restangularize the element using the standard requestless methods?

wastedUltimate avatar May 27 '15 17:05 wastedUltimate