A pure front-end angular captcha module.
npm install ng-captchaA pure front-end angular captcha module.
> 中文文档
```
npm install --save ng-captcha
app.module.ts
`ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from "@angular/forms";
import { CaptchaModule } from 'ng-captcha';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
CaptchaModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
`
app.component.html
`html`
app.component.ts
`ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
code
inputCode
onGenerateCode(code) {
this.code = code
}
verify() {
if (this.code === this.inputCode) {
alert('Verify success')
} else {
alert('Verify faild')
this.inputCode = undefined
}
}
}
`
Property | Description | Type | Default
--- | --- | --- | ---
width | Captcha Width | number | 100height | Captcha height | number | 50(generateCode) | The callback function that is triggered when the captcha changes, when component init or click can trigger. | EventEmitter