seandesmond / angular-payment

Native AngularJS (Angular) directives based heavily on Stripe's jQuery payment library. No 3rd party JS dependencies (jQuery, Stripe.js, etc.) required! http://seandesmond.github.io/angular-payment/
MIT License
51 stars 26 forks source link

modification on cvc formatters and expiry #12

Open wkjesus opened 9 years ago

wkjesus commented 9 years ago

i dont know how to make a pull request so i create this issue. sorry.

Hello, i found some issues with angular 1.3. + , when loading ngModel from a service, in this line was omittet de return value

.directive('cardCvcValidator', ['payment', function (payment) { 'use strict'; return { require: 'ngModel', link: function (scope, elm, attrs, ngModelCtrl) { function validate(value) { var valid = value ? payment.validateCardCvc(value) : false; ngModelCtrl.$setValidity('cardCvc', valid); return valid; }

            ngModelCtrl.$parsers.unshift(function (value) {
                return validate(value) ? value : undefined;
            });

            ngModelCtrl.$formatters.unshift(function (value) {
                validate(value);
           //add this line    return value;
            });
        }
    };
}]);

and is an issue on angluar 1.3 + with formatters when the value is an object it need push .. not unshift.

i hope this can help to perform you amazing directive.

eknowles commented 8 years ago

confirmed this works, please PR :)