I created an oauth2
service to use a Google API. The following line loads the JS Client library and registers an onload handler which fires when the library has finished loading:
<script src="https://apis.google.com/js/client.js?onload=load"></script>
My angular app is defined:
var myapp = angular.module('myapp', ['ui.state', 'ui.bootstrap', '$strap.directives']);
and the service
myapp.factory('oauth2', function($rootScope) {
this.load = function() {
console.log("Load...");
gapi.client.load('oauth2', 'v2', function() {
console.log("OAuth2 API loaded");
});
};
...
return this;
});
The load
callback is not called. I also tried oauth2.load
, myapp.load
but none of these work. How do you configure the onload
, to call oauth2.load
?