angular-payments icon indicating copy to clipboard operation
angular-payments copied to clipboard

Formatting needs better case handling: cut, paste, select, undo, redo, contextmenu

Open mpiasta-ca opened this issue 10 years ago • 2 comments

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..

mpiasta-ca avatar Jan 09 '15 03:01 mpiasta-ca

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.

benjamincharity avatar Apr 07 '15 16:04 benjamincharity

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.

bendrucker avatar May 04 '15 14:05 bendrucker