Skip to content

Instantly share code, notes, and snippets.

@mgonto
Created May 24, 2013 21:27
Show Gist options
  • Save mgonto/5646633 to your computer and use it in GitHub Desktop.
Save mgonto/5646633 to your computer and use it in GitHub Desktop.
$resource impl
var userResource = $resource('/users/:userId', {}, {
getList: {method: 'GET', params: {}, isArray: true},
get: {method: 'GET', params: {}, isArray: false},
});
var users = userResource.getList();
var user = userResource.get({userId: 123})
// Later in the code
var carResource = $resource('/users/:userId/cars/:carId', {}, {
getList: {method: 'GET', params: {}, isArray: true},
get: {method: 'GET', params: {}, isArray: false},
});
var oneCar = carResource.get(userId: 123, carId: 456);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment