I'm trying to understand the distinction between AngularJS $q
service and simply using .then()
after an asynchronous request.
For example, using .then()
:
function InboxService($http) {
this.getEmails = function getEmails() {
return $http.get('/emails');
};
}
And then when utilizing the service (snippet of code):
InboxService.getEmails()
.then(function (response) {
// handle response data
});
How does the $q
service differ, particularly with its ability to resolve and reject promises?