restangular
restangular copied to clipboard
Adding custom methods does not paly nice with the "one" method
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?