简体   繁体   English

如何在angularjs控制器范围内调用全局函数回调?

[英]How would I call a global function callback in the scope of a angularjs controller?

I'm trying to create something like this g+ login directive , which essentially adds something like 我正在尝试创建类似g + login指令的内容 ,它实际上添加了类似的内容

<span id="signinButton">
  <span
    class="g-signin"
    data-callback="signinCallback"
    data-clientid="CLIENT_ID"
    data-cookiepolicy="single_host_origin"
    data-requestvisibleactions="http://schemas.google.com/AddActivity"
    data-scope="https://www.googleapis.com/auth/plus.login">
  </span>
</span>

but I'm wondering how I add the data-callback function as a controller scope function? 但我想知道如何将data-callback函数添加为控制器作用域函数?

Currently it's just a global function. 当前,它只是一个全局函数。

See if this works for you: 看看这是否适合您:

function MyCtrl($scope) {
    $scope.signinCallack = function() { ... };
    window.signinCallback = $scope.signinCallback;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AngularJS - 我如何使用 $scope 在控制器中调用函数 - AngularJS - how can i call a function in a controller with $scope 如何使用$ scope方法在AngularJS控制器中调用函数? - How to call function in AngularJS controller with $scope method? AngularJS:如何从控制器调用在指令范围内定义的函数? - AngularJS: How do I call a function defined in a directive's scope from a controller? 如何从AngularJs组件的控制器类中调用全局函数 - How to call global function from controller class in AngularJs component 如何在全局回调函数中触发angularjs页面刷新? - How do I trigger a angularjs page refresh in a global callback function? 如何在AngularJS的另一个控制器中调用/使用$ scope的一个控制器 - How to call/use 1 controller of $scope in another controller in AngularJS AngularJS:从具有隔离范围的指令中调用控制器函数 - AngularJS : Call controller function from a directive with isolated scope 从html调用angularjs控制器中的函数,并且未定义范围变量 - call a function in angularjs controller from html and scope variable is not defined 如何从全局范围调用AngularJS JavaScript指令方法 - How to call AngularJS JavaScript directive methods from the global scope 如何在AngularJS控制器中调用javascript函数? - How can I call javascript function in AngularJS controller?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM