zlog
zlog

Reputation: 3316

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

<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?

Currently it's just a global function.

Upvotes: 2

Views: 1347

Answers (1)

Mark Rajcok
Mark Rajcok

Reputation: 364697

See if this works for you:

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

Upvotes: 4

Related Questions