Comments (4)
Hmm. Not really sure what to do about this. Thanks for reporting it, but I'm not willing to add something like this without a better understanding of what's going on.
from angular-credit-cards.
I think the issue was basically the watch doesn't fire immediately. So during typing the following is entered "4111222|"
, then the watch fires and adds the spaces, but for some reason it decides my caret should be back one space so the end result is this "4111 22|2"
. I also had the same issue using the backspace button as I'd end up skipping characters instead of spaces.
from angular-credit-cards.
It fires asynchronously? If you can manage to send a PR that tests this I'm game.
from angular-credit-cards.
I got it! It was the debounce effect - see here: http://plnkr.co/edit/PLZ6PqPc3cu0v9dqfnxW?p=preview
I ended up fixing it by replacing the actual watch with this:
$element.on('input', function formatInput () {
var input = $element.val();
var previous = $viewValue();
if (!input) return
var element = $element[0]
var formatted = card.format(card.parse(input))
//ngModel.$setViewValue(formatted)
var selectionEnd = element.selectionEnd
$element.val(formatted);
//ngModel.$render()
if (formatted && (!formatted.charAt(selectionEnd - 1).trim())) {
if (previous && previous.length < formatted.length) {
selectionEnd++
} else {
selectionEnd--
}
}
element.setSelectionRange(selectionEnd, selectionEnd)
})
Basically this fires before any of the watchers/formatters/parsers so it can't be delayed or intercepted without hooking into the input event again.
from angular-credit-cards.
Related Issues (20)
- Test card numbers showing wrong card type HOT 1
- Is there an exmample of cc-format markup? HOT 3
- cc-exp-month and cc-exp-year set incorrect validity keys HOT 6
- NgModel value is not updated HOT 1
- How can I use this in Angular4? HOT 1
- cc-number validation message when field is required HOT 2
- cc-exp and required message HOT 2
- [FIX] Temporary fix for ngRequired directive case HOT 3
- ng-model-options ignored? HOT 1
- Issue - CC input in google chrome Android Mobile HOT 3
- Problem with validating DISCOVER cards HOT 1
- Angular import overwrites angular global with webpack HOT 3
- Transposes numbers while typing HOT 5
- Angular 4? HOT 2
- Discover card is interpreted as Maestro HOT 1
- Wanna parse exp month as string. how?! HOT 1
- Transposed Numbers HOT 2
- Action required: Greenkeeper could not be activated 🚨
- Test Card Number 6011 1111 1111 1117 Incorrectly Identified HOT 2
- Can this work with angular > 1.7 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-credit-cards.