VividCortex / angular-recaptcha

AngularJS directive to add a reCaptcha widget to your form
http://vividcortex.github.io/angular-recaptcha/
MIT License
496 stars 257 forks source link

Resetting Recaptca on complete? #207

Open spacebiscuit opened 7 years ago

spacebiscuit commented 7 years ago

Once my form has been verified and I have processed the forms data, when complete I want to reset my form. I am doing this as follows:

$scope.contactForm.name = null;
$scope.contactForm.emailAddress = null;
$scope.contactForm.message = null;
$scope.contactForm.myRecaptchaResponse = null;                          
$scope.contactForm.$setPristine();

This works except for the re-captcha input, how can I reset this?

aghArdeshir commented 7 years ago

I had the same issue. a temporary hack/workaround could do the job now until issue is fixed.

it must erase the previous recaptcha and put a brand new one there in blink of an eye. : )

stanglt commented 6 years ago

You can inject the Recaptcha Service into your controller and reset it there. Typescript example:

module app {
[...]
this.$scope.contactForm.name = null;
this.$scope.contactForm.emailAddress = null;
this.$scope.contactForm.message = null;
this.$scope.contactForm.myRecaptchaResponse = null;                         
this.$scope.contactForm.$setPristine();

this.vcRecaptchaService.reload();
[...]
angular.module('app').controller('Controller', ['$scope', 'vcRecaptchaService']);
}