OTP verification input login implementation.
Highly configurable Angular otp verification. Compatible Angular 7+.
Online demo is here.
To install this component to an external project, follow the procedure:
- npm install otp-verification --save
- Add OtpVerificationModule import to your @NgModule like example below
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { OtpVerificationModule } from 'otp-verification'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, OtpVerificationModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }
- Add angular-otp-verification selector to template
<angular-otp-verification [isAlphanumeric]="true" (otpOut)="setOtp($event)"></angular-otp-verification>
Option | Default | Type | Description |
---|---|---|---|
isAlphanumeric | true | boolean | set to false if you need only numeric input |
- Called when the all the 4 digits are added,
- Output format is in string
setOtp(otp: string) {
console.log('the opt is ', otp);
}