0
调用AngularJS我有这样的指令:内<script>标签
function Recaptcha(RecaptchaService) {
return {
restrict: 'E',
templateUrl: 'app/components/login/recaptcha.html',
controller: function($scope) {
$scope.sendResp = function(response) {
RecaptchaService.sendResponse(response);
};
}
}
}
随着模板登录/验证码:
<script src='https://www.google.com/recaptcha/api.js'></script>
<script type="text/javascript">
var verifyCallback = function(response) {
$scope.sendResp(response);
};
</script>
<div class="g-recaptcha" data-sitekey="MY-KEY" data-callback="verifyCallback"></div>
所以,我想打电话给我$scope.sendResp
里面<script>
。但我得到$scope is not defined
。有没有办法做到这一点?
添加'verifyCallback'到控制器,并通过在裁判'$ scope'? http://stackoverflow.com/questions/16881478/how-to-call-a-method-defined-in-an-angularjs-directive – Pogrindis 2015-03-03 13:49:36
doens't工作,已经试过 – 2015-03-03 14:07:45
你的意思是$ scope.verifyCallback指令里面,并在数据回调中调用它,对吧? @Pogrindis – 2015-03-03 14:08:21