laurihy / angular-payments

Module that provides AngularJS-directives for formatting, validating and working with payments
560 stars 269 forks source link

Specific $scope bindings #108

Open steveops opened 8 years ago

steveops commented 8 years ago

Why must the inputs be bound to $scope.number, $scope.expiry and $scope.cvc? It would be very nice if they could be bound to any $scope property. For example my scope already has so many properties and I would like to group the stripe ones under $scope.stripe. Is this possible?

palfaro91 commented 6 years ago

I know this question is old but I too just stumbled upon this issue. Were you able to resolve the issue @steveops ?

thf24 commented 6 years ago

not sure if this is still relevant for someone, but in case:

you can achieve using $scope.stripe if you change in angular-payments.js in the method _getDataToSend the for(i in possibleKeys){ part to (I guess this is quite dirty but works for me):

for(i in possibleKeys){
        if(possibleKeys[i] == "number" || possibleKeys[i] == "cvc" ){
            ret[camelToSnake(possibleKeys[i])] = angular.copy(data.$parent.stripe[possibleKeys[i]]);
        } else {
            if(data.hasOwnProperty(possibleKeys[i])){
                ret[camelToSnake(possibleKeys[i])] = angular.copy(data[possibleKeys[i]]);
            }
        }
    }