Created
May 24, 2013 21:32
-
-
Save mgonto/5646659 to your computer and use it in GitHub Desktop.
Restangular impl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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