Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Commit

Permalink
Merge b296f81 into c59c81e
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmosh committed Jan 7, 2017
2 parents c59c81e + b296f81 commit 57543af
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
provider.onLoadFunctionName = onLoadFunctionName;
};

provider.$get = ['$rootScope','$window', '$q', function ($rootScope, $window, $q) {
provider.$get = ['$rootScope','$window', '$q', '$document', function ($rootScope, $window, $q, $document) {
var deferred = $q.defer(), promise = deferred.promise, instances = {}, recaptcha;

$window.vcRecaptchaApiLoadedCallback = $window.vcRecaptchaApiLoadedCallback || [];
Expand Down Expand Up @@ -133,6 +133,13 @@
// Check if grecaptcha is not defined already.
if (ng.isDefined($window.grecaptcha)) {
callback();
} else {
// Generate link on demand
var script = $document.get(0).createElement('script');
script.async = true;
script.defer = true;
script.src = 'https://www.google.com/recaptcha/api.js?onload='+provider.onLoadFunctionName+'&render=explicit';
$document.get(0).body.appendChild(script);
}

return {
Expand Down

0 comments on commit 57543af

Please sign in to comment.