@ortegaangelo/angular-signaturepad
v17.0.21
Published
Angular Component wrapper for szimek / signature_pad [fork from discontinued wulfsolter / angular2-signaturepad]
Downloads
235
Maintainers
Readme
angular2-signaturepad
Angular 17 component for szimek/signature_pad.
New maintained version
The original project is no longer maintained. See wulfsolter / angular2-signaturepad. I created a fork and will maintain it in the future.
Install
npm install https://gitlab.com/ortegaangelo/angular-signaturepad --save
Usage example
API is identical to szimek/signature_pad.
Options are as per szimek/signature_pad with the following additions:
- canvasWidth: width of the canvas (px)
- canvasHeight: height of the canvas (px) The above options are provided to avoid accessing the DOM directly from your component to adjust the canvas size.
// import into app module
import { SignaturePadModule } from '@ortegaangelo/angular-signaturepad';
...
@NgModule({
declarations: [ ],
imports: [ SignaturePadModule ],
providers: [ ],
bootstrap: [ AppComponent ]
})
// then import for use in a component
import { Component, ViewChild } from 'angular2/core';
import { SignaturePad } from '@ortegaangelo/signature-pad';
@Component({
template: '<signature-pad [options]="signaturePadOptions" (onBeginEvent)="drawStart()" (onEndEvent)="drawComplete()"></signature-pad>'
})
export class SignaturePadPage{
@ViewChild(SignaturePad) signaturePad: SignaturePad;
signaturePadOptions: Object = { // passed through to szimek/signature_pad constructor
'minWidth': 5,
'canvasWidth': 500,
'canvasHeight': 300
};
constructor() {
// no-op
}
ngAfterViewInit() {
// this.signaturePad is now available
this.signaturePad.set('minWidth', 5); // set szimek/signature_pad options at runtime
this.signaturePad.clear(); // invoke functions from szimek/signature_pad API
}
drawComplete() {
// will be notified of szimek/signature_pad's onEnd event
console.log(this.signaturePad.toDataURL());
}
drawStart() {
// will be notified of szimek/signature_pad's onBegin event
console.log('begin drawing');
}
}