Skip to content

Instantly share code, notes, and snippets.

@xcarpentier
Last active August 29, 2015 14:07
Show Gist options
  • Save xcarpentier/43aa846df272e74d0317 to your computer and use it in GitHub Desktop.
Save xcarpentier/43aa846df272e74d0317 to your computer and use it in GitHub Desktop.
/* A éviter */
function Order ($http, $q) {
var vm = this;
vm.checkCredit = checkCredit;
vm.total = 0;
function checkCredit () {
var orderTotal = vm.total;
return $http.get('api/creditcheck').then(function (data) {
var remaining = data.remaining;
return $q.when(!!(remaining > orderTotal));
});
};
}
/* Recommandé */
function Order (creditService) {
var vm = this;
vm.checkCredit = checkCredit;
vm.total = 0;
function checkCredit () {
return creditService.check();
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment