Skip to content

Instantly share code, notes, and snippets.

@zacharyblank
Created June 9, 2015 19:50
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 zacharyblank/90af2ebfb32ca26bd6bd to your computer and use it in GitHub Desktop.
Save zacharyblank/90af2ebfb32ca26bd6bd to your computer and use it in GitHub Desktop.
$q explained
this.get = function(data) {
var deferred = $q.defer();
resource.get(data, function(response) {
if (typeof response.data == 'object') {
deferred.resolve(new Venue(response.data));
} else {
deferred.reject();
}
}, function() {
deferred.reject();
});
return deferred.promise;
}
@zacharyblank
Copy link
Author

Venues.get().then(function(data) {
// do something with the data
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment