Issue
Google's platform.js
script for handling web logins can end in a callback to initiate some function in our code:
<script src="https://apis.google.com/js/platform.js?onload=appStart" async defer>
In spite of the many Angular tutorials and examples, I have yet to find a way to have this callback execute in an Angular controller. How do I connect this callback to an Angular controller or other appropriate mechanism of Angular?
Solution
I was able to inject $window
into my controller and direct third party code there. This is the result:
var app = angular.module('ga',[]);
app.controller('gac', function($scope, $window) {
$window.appStart = function() {
console.log('appStart()');
gapi.load('auth2', initSigninV2);
};
// additional functions omitted. refer to demo
}
Note when third parties call functions in Angular, it may be necessary to update the scope with $scope.$digest()
.
Demo: http://jameswclark.github.io/Google-Web-Login/
Answered By - ThisClark
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.