Created
December 11, 2013 08:27
-
-
Save robwormald/7906836 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//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