angular-fancy-url

$http.get('api://users/1'); // human readable configured url


License
MIT
Install
bower install angular-fancy-url

Documentation

angular-fancy-url Build Status

(Related Article)

Just do

app.service('myService', function($http) {
  // GET http://api.example.com/users
  return $http.get('api://users');
});

No more

app.service('myService', function($http, apiUrl) {
  // GET http://api.example.com/users
  return $http.get(apiUrl + '/users');
});
  • Flexibility — interceptors for the win !
  • Readability — no extras string concatenation or helper calls
  • “Testability”

Usage

bower install angular-fancy-url --save

then

angular.module('myApplication', [
   'fancyURL'
]).config(function($httpProvider, httpFancyURLProvider) {
   $httpProvider.interceptors.push('httpFancyURL');

   httpFancyURLProvider.use({
      'api' : 'http://api.example.com/',
   });
})