Code is from Jeremy Elbourn. Added to bower because I think I will be re-using this a lot.
0.0.1
bower install angular-api-provider
-
Add module dependency 'ngApiProvider' :
angular.module('foo', ['ngApiProvider',..])
-
Initialize provider:
.config(function(apiProvider) { apiProvider.setBaseRoute('my/app/api/'); apiProvider.endpoint('songs'). route('songs/:id'). model(app.Song); apiProvider.endpoint('albums'). route('albums/:id'). model(app.Album); });
-
Use in controller:
app.SongController = function($scope, $routeParams, api) { var songs = api.songs.get({id: $routeParams.id}); };
MIT
Free Software, Hell Yeah!