High-Level Problem:
- I'd like to know if the current user is logged into Google Plus.
Partial Solution:
Specify a callback method to the onload parameter.
po.src = 'https://apis.google.com/js/client:plusone.js?onload=signinCallback';
Complication:
- I've put all of the Google Plus JavaScript code inside of an AngularJS provider.
Specific Problem:
- I'd like to attach a callback method to the onload parameter, but the asynchronous JavaScript fetch of
https://apis.google.com/js/client.js
is occurring inside of AngularJS's run method.
-> Initialization of module:
.run([function() {
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://apis.google.com/js/client.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
}]);
Although Google recommends that you fetch https://apis.google.com/js/client.js
asynchronously, I'm not wedded to it. But I would like to keep most of that Google+ integration code inside of either an AngularJS Provider or an AngularJS service.
Any help would be appreciated.