1.0.3 • Published 1 year ago

ngx-aadharinput-directive v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

NgxAadharinputDirective

This library was generated with Angular CLI version 12.0.5.

How To Install

npm i ngx-aadharinput-directive

How To Use

Import NgxNumberonlyDirectiveModule module in your app module

import { NgxAadharinputDirectiveModule } from 'ngx-Aadharinput-Directive';
@NgModule({
  declarations: [
  ],
  imports: [
    NgxAadharinputDirectiveModule,
  ],
})

In your HTML code

 <mat-form-field appearance="outline">
   <mat-label>Aadhar Number</mat-label>
   <input matInput placeholder="Aadhar Number" 
   [(ngModel)]="Aadhar"
   AadharInput (validaadharno)="checkaadarno($event)">
   <mat-icon matSuffix *ngIf="ValidAadharnumber && Aadhar.length == 14" class="valid">check_circle</mat-icon>
   <mat-icon matSuffix *ngIf="!ValidAadharnumber && Aadhar.length == 14" class="invalid">cancel</mat-icon>
 </mat-form-field>

In your component .ts file declare 2 variables like below Note: use can use form control instead of ngModel

Aadhar: string = '';
ValidAadharnumber: boolean;

This function return entered Aadhar number is valid or not (boolean)

checkaadarno(val: any){
  this.ValidAadharnumber = val;
}

Also, you can use this service to check given Aadhar number is valid or not Note: you have to pass the Aadhar number in string format without space or special character

constructor(private ngservice: AadharvalidationService) { }
let validaadhar = this.ngservice.validateAdhar('123412341234');