Q extensions to AngularJS' $q Implementation
Warning: There is not much here right now, but I plan to expand the API as much as is reasonable.
Pour some sugar on $q? Mostly wanted to see if it was possible.
bower install ng-qnpm install && npm testInclude q.module.js or q.module.min.js.
angular.module('myModule', ['ng.q'])
// trivial example; foo() and bar() are functionally equivalent.
function MyCtrl($scope, $q, $http) {
$scope.foo = function() {
return $http.get('/some/url')
.then(function(res) {
return res.data;
});
});
};
$scope.bar = function() {
return $http.get('/some/url')
.get('data');
};
};Promise objects now have the following functions:
-
get(): See Q API docs. -
post(): See Q API docs.
Christopher Hiller <chiller@badwing.com>