Last active
August 29, 2015 14:07
-
-
Save xcarpentier/43aa846df272e74d0317 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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