title: Call Angular controller from script onload
body: <p>I am trying to update the state of my controller after loading of a script from onload callback.</p>
  
  <p>I load the Google Client API:</p>
  
  <pre><code>&lt;script src="https://apis.google.com/js/client.js?onload=OnLoadCallback"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Then in OnLoadCallback I try to manually bootstrap AngularJS and set the set state on to my controller:</p>
  
  <pre><code>function OnLoadCallback() {         
        var $injector = angular.bootstrap(document, ['app']);
        // load required gapi APIs          
        var $controller = $injector.get('$controller');        
        var UserCtrl = $controller('UserCtrl');
        UserCtrl.user.apiLoaded = true;          
  };
  </code></pre>
  
  <p>It cannot seem to create a controller with the $scope injected. As the call <code>$controller('UserCtrl')</code> fails with:</p>
  
  <blockquote>
    <p>Uncaught Error: Unknown provider: $scopeProvider &lt;- $scope</p>
  </blockquote>
  
  <p>You can see the error by viewing the console in this <a href="http://plnkr.co/edit/X4iG5iOw1k70fR8NayYc?p=preview" rel="nofollow">Plunk</a>.</p>