legalthings / angular-signature

HTML5 canvas based smooth signature drawing as angularJS directive (http://szimek.github.io/signature_pad/)
MIT License
105 stars 91 forks source link

Huge typo. signature.js line 31-32. Missing signature.dataUrl assignment. #38

Closed btcpbordeaux closed 7 years ago

btcpbordeaux commented 7 years ago

You have a massive typo FYI. In the definition of $scope.accept you have ( commit https://github.com/legalthings/angular-signature/commit/df28083f41b557184f340cb26765881b8eb253ec for reference )

          $scope.accept = function () {
                var signature = {};
                if (!$scope.signaturePad.isEmpty()) {
                    signature.isEmpty = false;
                } else {
                    signature.dataUrl = EMPTY_IMAGE;
                    signature.isEmpty = true;
                }

                return signature;
            };

...

should be

 $scope.accept = function () {
                var signature = {};

                if (!$scope.signaturePad.isEmpty()) {
                    signature.isEmpty = false;
                    //WHY WAS THIS MISSSING?!?!?!?!
                    signature.dataUrl = $scope.signaturePad.toDataURL("image/gif");
                } else {
                    signature.dataUrl = EMPTY_IMAGE;
                    signature.isEmpty = true;
                }

                return signature;
            };

So the scope item which is set equal to the directive's 'accept' attribute would be only {isEmpty = false}. With the change above, That line was in the code but someone took it out in an update. For the life of me, I could not figure out why, because the directive loses half of its functionality.

jasny commented 7 years ago

Already fixed. See #36. Just waiting for peer review to accept te changes.