Skip to content

Instantly share code, notes, and snippets.

@2roy999
Created May 12, 2015 11:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2roy999/ca2932c507e39443ca53 to your computer and use it in GitHub Desktop.
Save 2roy999/ca2932c507e39443ca53 to your computer and use it in GitHub Desktop.
A angular directive to signature_pad
angular.module('SignaturePad', [])
.directive('SignaturePad', function () {
return {
restrict: 'A',
require: '?ngModel',
link: function (scope, element, attrs, ngModel) {
if (!ngModel) return;
var signaturePad = new SignaturePad(element[0]);
ngModel.$render = function () {
signaturePad.fromDataURL(ngModel.$viewValue)
};
signaturePad.onEnd = function () {
scope.$evalAsync(read);
};
read();
function read() {
var dataUrl = signaturePad.toDataURL();
ngModel.$setViewValue(dataUrl);
}
}
}
})
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment