2

I'm using ngResource to consume a RESTful API, and have implemented the following service:

app.factory('User', function($resource) {
  return $resource('/api/users/:id', { id: '@id' });
});

I would like to pass in a subdomain to it. Is there a way to do this?

I'm aware of the following workarounds:

  1. Pass in a full URL: api.acme.com/users/:id
  2. Inject a variable on the url: `'api.' + mydomain + '/users/:id'

With that said, I believe it'd be cleaner to just send the subdoman as an argument. Can this be done?

rebagliatte
  • 2,110
  • 1
  • 20
  • 25

0 Answers0