title: Detecting that Angular 2 is done running
body: <p>We use Selenium WebDriver to automate our UI based tests.  One of our challenges is to detect when a page is truly done loading, and Angular 1 was a challenge in that regard as well.  We ended up executing this piece of code specifically to detect if Angular 1 is done:</p>
  
  <pre><code>if(typeof window.angular !== \"undefined\")
  {
    var injector = window.angular.element(\"*[ng-app]\").eq(0).injector();
  
    if(injector)
    {
      var $rootScope = injector.get(\"$rootScope\");
      var $http = injector.get(\"$http\");
  
      if($rootScope.$$phase === \"$apply\" || $rootScope.$$phase === \"$digest\" || $http.pendingRequests.length !== 0)
      {
        return false;
      }
    }
  }
  </code></pre>
  
  <p>The app that we are testing recently switched over to use Angular 2.  The code snippet above does not wait for Angular 2 to finish.  Any suggestions?</p>