Skip to content

Instantly share code, notes, and snippets.

@robwormald
Created December 11, 2013 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robwormald/7906836 to your computer and use it in GitHub Desktop.
Save robwormald/7906836 to your computer and use it in GitHub Desktop.
//psudeo code
//service
app.factory('User',function(restangular){
var UserModel = restangular.all('user')
return {
allUsers : UserModel.getList()
}
})
//controller
app.controller('myController',function(User){
//note the promise is automatically resolved here... you don't have to handle the .then()
$scope.users = User.allUsers();
$scope.updateUser = function(userInstance){
//but you can if you want to ...
userInstance.put().then(function(){
//user successfully updated;
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment