title: Trying to inject $window into angular factory using typescript
body: <p>I am trying to inject $winow into my factory.</p>
  
  <p>Here is my factory and class definition</p>
  
  <pre><code> export interface IAuthToken {
   }
  
   export class AuthToken implements IAuthToken {
       storage: Storage;
       constructor(private $window: ng.IWindowService) {
          this.storage = this.$window.localStorage;
       }
  
      factory.$inject = ['$window'];
      function factory($window: ng.IWindowService): IAuthToken {
          return new AuthToken(this.$window);
      }
  
      angular
          .module('test')
          .factory('app.common.auth.AuthToken', factory);
  }
  </code></pre>
  
  <p>When I debug the code the $window is always set to undefined. I have attempted to add the injection when registering the factory itself and I still get the $window as undefined?</p>
  
  <pre><code>function factory($window: ng.IWindowService): IAuthToken {
      return new AuthToken(this.$window);
  }
  
  angular
      .module('test')
      .factory('app.common.auth.AuthToken', ['$window',factory]);
  </code></pre>
  
  <p>Any help would be greatly appreciated.
  Thanks in advance.</p>