function renderAndVerifyGoogleCpatcha() { var siteKeyElement = document.getElementById("sitekey"); var siteKey = siteKeyElement && siteKeyElement.value; var captchaVerified = false; var verifyCallback = function(grc) { captchaVerified = !!grc; angular.element("#captchaVerified").attr("value", captchaVerified); //token object values can be set depending on the captcha provider. var token = { captchaVerified: captchaVerified, token_id: grc }; angular.element('#captchaVerified').scope().$root.$broadcast('captchaVerified', token); }; var captchaWidget = grecaptcha.render('html_element', { 'sitekey': siteKey, 'callback': verifyCallback, 'theme': 'light', 'expired-callback': function() { angular.element("#captchaVerified").attr("value", captchaVerified); var token = { captchaVerified: false, token_id: null }; angular.element('#captchaVerified').scope().$root.$broadcast('captchaVerified', token); } }); } $.getScript("https://www.google.com/recaptcha/api.js?onload=renderAndVerifyGoogleCpatcha&render=explicit");