Skip to content

Commit

Permalink
Code cleanup; Added instructions for usage
Browse files Browse the repository at this point in the history
  • Loading branch information
nogorilla committed Nov 17, 2016
1 parent 54e6dec commit b934542
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
41 changes: 24 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,33 @@ Angular2 CC Library - for validation and formating of input parameters

# Usage

## Installation
```shell
npm install ng2-cc-library --save
```


## Formating Directive
On the input fields, add the specific directive to format inputs.
All fields must be `type='tel'` in order to support spacing and additional characters

```javascript
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { CreditCardDirectivesModule } from 'ng2-cc-library'

import { AppComponent } from './app.component';

@NgModule({
imports: [BrowserModule, FormsModule, CreditCardDirectivesModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {
}
```

**Credit Card Formater**
* add `ccNumber` directive:
```html
Expand All @@ -36,25 +59,9 @@ Will support format of MM/YY or MM/YYYY
### Validation
Current only Model Validation is supported.
To implement, import the validator library and apply the specific validator on each form control
```javascript
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { CreditCardDirectivesModule } from 'ng2-cc-library'

import { AppComponent } from './app.component';

@NgModule({
imports: [BrowserModule, FormsModule, CreditCardDirectivesModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {
}
```

```javascript
import { CreditCardValidator } from '../../src/validators/credit-card.validator';
import { CreditCardValidator } from 'ng2-cc-library';

@Component({
selector: 'app',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng2-cc-library",
"version": "0.0.7",
"version": "1.0.0",
"description": "angular2 credit card library",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
1 change: 0 additions & 1 deletion src/directives/expiry-format.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export class ExpirayFormatDirective {
}

@HostListener('keypress', ['$event']) onKeypress(e) {
console.log(CreditCard.restrictExpiry(e.which, this.target));
if (CreditCard.restrictNumeric(e) && CreditCard.restrictExpiry(e.which, this.target)) {
this.formatExpiry(e);
this.formatForwardSlashAndSpace(e);
Expand Down

0 comments on commit b934542

Please sign in to comment.