如何为Angular App创建自定义otp输入字段?



我正在Angular上工作,我正在使用otp代码。我想添加自定义otp输入,而不是任何第三方包。如果有人知道如何为angular创建一个,我将不胜感激。

谢谢!

您可以通过以下链接创建和使用OTP输入

安装npm Package
npm install --save ng-otp-input

2-导入NgOtpInputModule

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { NgOtpInputModule } from 'ng-otp-input';
@NgModule({ 
declarations: [AppComponent], 
imports: [BrowserModule, NgOtpInputModule], 
bootstrap: [AppComponent] 
})

3-使用它!

<ng-otp-input (onInputChange)="onOtpChange($event)" [config]="{length:5}"></ng-otp-input>

你也可以在这里看到现场演示

最新更新