title: how do I inject `$rootScope` using TypeScript static injector pattern?
body: <p>So, finally after getting a large model to compile in both angular and typescript, I get this runtime error:</p>
  
  <blockquote>
    <p>10angular.js:12314 Error: [ng:cpws] Can't copy! Making copies of
    Window or Scope instances is not supported.
        <a href="http://errors.angularjs.org/1.4.1/ng/cpws" rel="nofollow">http://errors.angularjs.org/1.4.1/ng/cpws</a></p>
  </blockquote>
  
  <pre><code>at angular.js:68
  at copy (angular.js:857)
  at copy (angular.js:932)
  at copy (angular.js:888)
  at Scope.$digest (angular.js:15666)
  at Scope.$apply (angular.js:15935)
  at bootstrapApply (angular.js:1624)
  at Object.invoke (angular.js:4443)
  at doBootstrap (angular.js:1622)
  at bootstrap (angular.js:1642)
  </code></pre>
  
  <p>I did not change any "implementation" I only re-structured classes to use TypeScript. Nowhere in my code to a use angular.copy (in any classes in the whole app). After much beating my head against the wall, I stumbled across the problem. The constructor assigns $rootScope to a local variable (that due to TS, is now on the prototype). Now, this was kind of old code and I was only using a ref to $rootScope to use it as a generic event dispatcher to all the view controllers using <code>$rootScope.broadcast(...)</code>. It used to work fine when I injected it using the standard angular boilerplate, and I could refactor it...</p>
  
  <pre><code>/// &lt;reference path="../../app/reference.ts" /&gt;
  class UserModel {
    roles:string;
    activeRole:string;
    errorString:string;
    loginAttemptEmailValue:string;
    successString:string;
  
  static $inject = ['utils', '$rootScope','$q', '$cookies', '$http','settings', '$location'];
    constructor(u,r,q,c,h,s,l) {
      this.utils = u;
      this.rootScope = r; // &lt;---- the problem. comment-out this line and it works.
      this.q = q;
      this.cookies = c;
      this.http = h;
      this.settings = s;
      this.location = l;
    }
  ...
  
  angular.module('App').service('userModel', UserModel );
  </code></pre>
  
  <p><strong>But this makes me concerned</strong> that when I go to convert my controllers I will have the same problem just injecting $scope. </p>
  
  <p>So, my question is, how do I properly inject <code>$scope</code> using this TypeScript static injector pattern without getting this dreaded copy error? </p>
  
  <p>I tried making a class-level static scope variable, but of course you get a left-hand assignment error trying to assign to a static type.</p>
  
  <p><strong>UPDATE:</strong> 
  Here's the transpiled js. </p>
  
  <pre><code>var UserModel = (function () {
      function UserModel(u, r, q, c, h, s, l) {
          var _this = this;
  
          this.utils = u;
          this.rootScope = r;
          this.q = q;
          this.cookies = c;
          this.http = h;
          this.settings = s;
          this.location = l;
      }
      UserModel.prototype.hasActiveRole = function (val) {
          if (this.activeRole === val) {
              return true;
          }
          return false;
      };
      //...other implementation...
      UserModel.$inject = ['utils', '$rootScope', '$q', '$cookies', '$http', 'settings', '$location'];
      return UserModel;
  })();
  angular.module('App').service('userModel', UserModel);
  </code></pre>