Last active
May 12, 2016 14:26
-
-
Save rbinksy/3300c785b63a043322687a43a00aa103 to your computer and use it in GitHub Desktop.
This file contains 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
CardDirective.$inject = ['VicStripeService', 'vicPayments']; | |
function CardDirective(VicStripeService, vicPayments){ | |
return { | |
restrict: 'E', | |
scope: { | |
card: '=' | |
}, | |
templateUrl: function(elem, attrs) { | |
return attrs.template || 'victor/stripeForm.html'; | |
}, | |
controllerAs: 'vm', | |
bindToController: true, | |
controller: function($scope) { | |
var vm = this; | |
vm.paymentsService = vicPayments; | |
vm.cardTypeClass = 'vic-card-type-unknown'; | |
$scope.$watch('card.number', function(){ | |
vm.cardTypeClass = 'vic-card-type-' + VicStripeService.getCardType(vm.card.number).toLowerCase(); | |
vm.card.cardType = VicStripeService.getCardType(vm.card.number).toLowerCase(); | |
}); | |
} | |
}; | |
} | |
templateCache.$inject = ['$templateCache']; | |
function templateCache($templateCache) { | |
var tpl = [ //<troll>JSX</troll> | |
'<div>', | |
'<section id="form-placeholder"></section>', | |
'<div class="row" ng-init="card = card || {}">', | |
'<div class="form-group col-xs-2">', | |
'<span ng-class="{{vm.cardTypeClass}}"></span>', | |
'</div>', | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment