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

Directive is not work, I don't understand why? #193

Closed dmitryprogrammer closed 7 years ago

dmitryprogrammer commented 7 years ago

Hi, as I understand, I need just include 'vcRecaptcha' module into my app. So, now I'm trying to use vc-recaptcha in my component (angular 1.6), after rendering my component, I don't see any error in console and recaptcha interface too. I learn directive code, and found next things:

  1. When validation occurs in removeCreationListener, angular expressions is not parsed. I mean this

    if (key.length !== 40) {
    throwNoKeyException();
    }

    in key will be string callback.captchaKey, callback is name which was assigned in controllerAs, captchaKey - is a attribute which was passed into my component.

  2. If I call vc-recaptcha not in component, and into key attr passed php variable, first point will work correctly, but recaptcha interface will not build anyway. I learned code deeper and found next thing. The interpreter can't come into then because variable recaptcha in getRecaptcha method, which calls in method create is undefined. It's undefined because the callback function was not called

    var callback = function () {
    recaptcha = $window.grecaptcha;
    
    deferred.resolve(recaptcha);
    };

I don't have expert skills in angular, and maybe problem on my side, but I write here because I need help. Thanks.

I want say couple of words more. Promise which getRecaptcha() returns is empty

return getRecaptcha().then(function (recaptcha) {
        var widgetId = recaptcha.render(elm, conf);
    instances[widgetId] = elm;
    return widgetId;
});

Interpreter can't call resolve and reject too. I included recaptcha module into webpack bundle, and browser can work with it, so problem in code I think. But I can't be sure it's bug in directive code, or I did mistake where called it.

Call looks like that <div key="'<?php echo Authorization_model::RECAPTCHA_PUBLIC ?>'" vc-recaptcha></div>

jackkum commented 7 years ago

I can't understand what are you doing? Can you show the code?

Maybe this can help you https://embed.plnkr.co/ITb5h2/