Using a full URL with Restangular

cazzaran picture cazzaran · Aug 1, 2013 · Viewed 12.5k times · Source

I like all of the functions of Restangular for AngularJS, except that I can't find (and it may not support) a way of just passing a full URL to it. I realize the benefit of the .one('something','someparam') but my issue is that I'm passed various URL strings, and I really don't want to have to split() them just to use Restangular.

Also, I know about the baseURL function; but these URLs I'm being passed don't necessarily derive from the same base path.

For example, I might have:

/us/en/product/17726
/us/es/products
/us/es/product/991A0
/ca/en/accounts

All I'm given are the Strings...

Answer

mgonto picture mgonto · Aug 1, 2013

I'm the creator of Restangular.

You have 2 options to do that.

1) Creating scoped Restangulars with different BaseURLs in each case: https://github.com/mgonto/restangular#how-to-create-a-restangular-service-with-a-different-configuration-from-the-global-one

2) You can use it like Restangular.all('us/en/').one('products', 1726) or Restangular.one('us/en/product', 1234)

Hope it works for you :)