Comments (2)
I found a workaround that seems to work. In the safeVal() method in credit-card.ts, I advance the cursor by one if it's at the end of a 4 digit segment:
try {
cursor = target.selectionStart;
if(cursor==4 || cursor==9 || cursor==14 || cursor==19){
cursor++;
}
} catch (error) {}
from angular-cc-library.
I refined it a little further to automatically delete the value to the right of the space, and also only do so if they hit the Delete key. In the reFormatCardNumber() method of credit-card-directive, I check if it's a Delete event:
if(e instanceof KeyboardEvent && e.code.toUpperCase()=='DELETE')
deleteKey = true;
Pass that deleteKey flag as a new boolean input to safeVal(), then only if a delete was performed, advance the cursor and delete the digit past the space.
try {
cursor = target.selectionStart;
if(deleteKey && (cursor==4 || cursor==9 || cursor==14 || cursor==19)){
cursor++;
// simulate another delete event by removing the character the user would have indented to delete
let preDeleteSegment = value.substring(0, cursor);
let postDeleteSegment = value.substring(cursor+1, value.length);
value = preDeleteSegment+postDeleteSegment;
}
} catch (error) {}
from angular-cc-library.
Related Issues (20)
- Angular 12 support please? HOT 2
- Request for Angular v13 Support HOT 2
- Angular 14 Support HOT 5
- Not compatible with Angular 15 HOT 7
- Compatibility issues with Angular 14 HOT 6
- angular-cc-library is not compatible with angular v16 HOT 2
- Looking for maintainers HOT 20
- Roadmap HOT 1
- v2 broke compatibilty with Ionic HOT 1
- Cvv & Exp date not validating HOT 2
- Error in ng build --prod HOT 2
- Add supporting two inputs for expiry HOT 1
- Support Angular 10 HOT 6
- Provide pipes HOT 1
- Error in credit card validation HOT 1
- cc-exp autocomplete does not work on safari HOT 2
- Only arrays and iterables are allowed Error HOT 1
- Cannot find module 'angular-cc-library' or its corresponding type declarations. HOT 1
- Formcontrol issue HOT 1
- Missing releases !! HOT 3
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-cc-library.