Skip to content

Instantly share code, notes, and snippets.

@mgonto
Created May 24, 2013 21:32
Show Gist options
  • Save mgonto/5646659 to your computer and use it in GitHub Desktop.
Save mgonto/5646659 to your computer and use it in GitHub Desktop.
Restangular impl
// Assigning promise
// GET /api/v1/users
var users = Restangular.all('users').getList();
// GET /api/v1/users/123
var user = Restangular.one('users',123).get();
// Assigning value
// GET /api/v1/users
Restangular.all('users').getList().success(function(users) {
var firstUser = users[0];
// GET /api/v1/users/456/cars assuming first user id is 456
var cars = firstUser.getList('cars');
// GET /api/v1/users/456/cars/777 assuming first user id is 456
var carWithId = firstUser.one('cars', 777).get()
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment