Let\'s say a service like this:
services.factory(\'User\', function($resource){
return $resource(\'/rest/usersettings/:username\', {}, {
User.get( {username: 'bob'} )
does not return your actual data immediately. It returns something will hold your data when the ajax returns. On that (the $promise
), you can register an additional callback to log your data.
You can change your code to:
scope.user = User.get( {username: 'bob'} ); // GET
scope.user.$promise.then(function(data) {
console.log(data);
});