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

.then method for vcRecaptchaService.execute()? #213

Closed RaghuMurugesan closed 7 years ago

RaghuMurugesan commented 7 years ago

I am using anuglar-recaptcha for adding Google Invisible Recaptcha to my login form

The issue I am facing is, immediately after I call vcRecaptchaService.execute, if I print the recaptcha_reponse I will see undefined as output. But if I print recaptcha_reponse few seconds afterwards by using a test function printRecaptchaReponse I will see the recaptcha_reponse getting printed.

The Issue here is, the library function vcRecaptchaService.execute() is not returning a $promise here. Its actually returning none

Is there any way to promisify this ?

Whats the ISSUE:

// 1. Call this function from html first $scope.testRecaptchaExecute = function() { vcRecaptchaService.execute($scope.widgetId); console.log($scope.user.recaptcha_reponse); // undefined return(); } // 2. Call this function from html few seconds after testRecaptchaExecute() is called $scope.printRecaptchaReponse = function() { console.log($scope.user.recaptcha_reponse); //JVRk4cZ4J_RluoH2 }

WHAT I want: vcRecaptchaService.execute().then(ret => { //do something here })

Question Summary How to use .then method for vcRecaptchaService.execute()?

RaghuMurugesan commented 7 years ago

Refer to this stackoverflow discussion for solution