ng-otp-fields
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

NgOtpFields

A lightweight and highly customizable Angular OTP component.

Build Status

Install

$ npm install --save ng-otp-fields

Usage

// in app.module.ts
import { NgOtpFieldsModule } from 'ng-otp-fields';

@NgModule({
  ...
  imports: [
    NgOtpFieldsModule
  ],
  ...
})
export class AppModule { }
<!-- in app.component.html -->
<ng-otp-fields  (onInputChange)="onOtpChange($event)"  [config]="config"></ng-otp-fields>
// in app.component.ts
config: Config = {
  length:8, 
  inputClass: 'input', 
  containerClass: 'input--key',
  allowNumbersOnly: true, 
  isPasswordInput: true
 }

onOtpChange(event) {
  console.log(event);
}

Component documentation

ng-otp-input

This component has the following Input properties:

  • [config]: Configuration object.

It has the following Output event:

  • (onInputChange): Emitted when any input is changed. It returns the value of fields in a string.

Configuration object

// configuration object

{
    inputStyles?: {[key: string]: any}; // default empty
    containerStyles?: {[key: string]: any}; // default empty
    allowKeyCodes?: string[]; // default empty
    length: number; // default 4
    allowNumbersOnly?: boolean; // default false
    inputClass?: string; // default empty
    containerClass?: string; // default empty
    isPasswordInput?: boolean; // default false
    disableAutoFocus?: boolean; // default false
    placeholder?: string; // default empty
}

Licence

MIT ©

Readme

Keywords

none

Package Sidebar

Install

npm i ng-otp-fields

Weekly Downloads

0

Version

0.0.5

License

MIT

Unpacked Size

218 kB

Total Files

35

Last publish

Collaborators

  • mfsanchez