Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.