title: AngularJS undefined error on $document.context.addEventListener
body: <p>I have the following angular service:</p>
  
  <pre><code>.factory("OTReady", ['$document', function ($document) {
    var ready = false;
    $document.context.addEventListener('deviceReady', function () {
      ready = true;
    });
  
    return (function(fn){
      if (ready) {
        fn();
      } else {
        $document.context.addEventListener('deviceReady', fn);
      }
    });
  }])
  </code></pre>
  
  <p>And this is returning "undefined". It's a snippet from an <a href="https://github.com/aullman/OpenTok-Angular" rel="nofollow">opentok-angular  library</a> running in Cordova.</p>
  
  <p>Many other $document properties are available at in this block of code. Why this is returning "undefined" ? </p>