angular-payments
angular-payments copied to clipboard
Formatting needs better case handling: cut, paste, select, undo, redo, contextmenu
It's really basic at the moment, lots of cases are not being handled. Might be worth to port-in a complete jQuery solution instead. I'm working on a business project and took a more complex approach to formatting the card number. What I do is upon any change, I flash the reformatted card number, and then I position the caret back to its expected position. It's a lot of work, but the finished result is much smoother.
You may also want to refrain from using event.preventDefault(), as this stops the scope on the field from $digesting. So if another directive is watching a change to the value, it won't be propagated as expected..
Big +1 to rethinking the $digest blocking. A bound model should always contain the content. IMO a plugin should never overwrite a piece of core framework functionality unless that plugin is specifically designed to do just that. We shouldn't need a work-around just to know if an input has content.
Give angular-credit-cards 2.3 a shot. I've added formatting that does a reasonably good job of getting the cursor position right without breaking out of Angular's native input handling events.