title: Load Google JS Client library in AngularJS
body: <p>I created an <code>oauth2</code> 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:</p>
  
  <pre><code>&lt;script src="https://apis.google.com/js/client.js?onload=load"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>My angular app is defined:</p>
  
  <pre><code>var myapp = angular.module('myapp', ['ui.state', 'ui.bootstrap', '$strap.directives']);
  </code></pre>
  
  <p>and the service</p>
  
  <pre><code>myapp.factory('oauth2', function($rootScope) {
      this.load = function() {
          console.log("Load...");
          gapi.client.load('oauth2', 'v2', function() {
              console.log("OAuth2 API loaded");
          });
      };
  
      ...
  
      return this;
  });
  </code></pre>
  
  <p>The <code>load</code> callback is not called. I also tried <code>oauth2.load</code>, <code>myapp.load</code> but none of these work. How do you configure the <code>onload</code>, to call <code>oauth2.load</code>?</p>